Re: [go-nuts] Statically linking cgo

2016-12-24 Thread Matt Harden
Try this? http://blog.madewithdrew.com/post/statically-linking-c-to-go/

On Sat, Dec 24, 2016 at 6:58 PM Justin Israel 
wrote:

>
>
> On Sun, Dec 25, 2016, 2:43 PM James Pettyjohn 
> wrote:
>
> Hi Justin,
>
> Thanks for the holiday reply.
>
> The ultimate goal in this was deployment into docker as a self contained
> binary, no dynamic library dependencies and no parent image. The most
> common solution to this I've seen is disable CGO altogether but with the
> libraries I'm using this is not an option at this time.
>
>
> Right. But you still need cgo for the C dependency so there is no way to
> disable it. You can only statically link as much as possible. I can't
> confirm right now but I think that may still leave you with a libc dynamic
> link at the very least
>
>
>
> Best,
> James
>
> On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote:
>
>
>
> On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn 
> wrote:
>
> I've been looking at a number of articles on statically linking go files
> by disabling CGO, sounds great except I've got a libsass dependency until
> the native libsass is ready.
>
> Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)?
>
>
> Are you asking about statically linking libsass?
>
> In addition to other flags to statically link your Go binary, you can tell
> cgo to statically link libsass:
>
> $ export CGO_LDFLAGS="\
> -Wl,-Bstatic \
> `pkg-config --libs libsass` \
> -lotherDep -lotherDep2
> -Wl,-Bdynamic"
>
> ​
>
> - Justin
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
>
>
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Converting escaped unicode to utf8

2016-12-24 Thread Matt Harden
If it has a JSON body, are you using encoding/json to parse / decode it?
That will handle the unescaping for you.

On Sat, Dec 24, 2016 at 4:54 PM JohnGB  wrote:

> I have an application where I am processing a HTTP request with a JSON
> body.  However, the JSON in the body has been unicode escaped, so instead
> of `wasn't`, I get `wasn\u0027t`.
>
> What is the simplest way to unescape this text back to utf8 encoded text.
>  i.e. convert `wasn\u0027t` to `wasn't`.  Please note that I'm only using
> this as an example, but I'd like all unicode escaped characters to be
> converted to their utf8 equivalents.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Statically linking cgo

2016-12-24 Thread Justin Israel
On Sun, Dec 25, 2016, 2:43 PM James Pettyjohn  wrote:

> Hi Justin,
>
> Thanks for the holiday reply.
>
> The ultimate goal in this was deployment into docker as a self contained
> binary, no dynamic library dependencies and no parent image. The most
> common solution to this I've seen is disable CGO altogether but with the
> libraries I'm using this is not an option at this time.
>

Right. But you still need cgo for the C dependency so there is no way to
disable it. You can only statically link as much as possible. I can't
confirm right now but I think that may still leave you with a libc dynamic
link at the very least



> Best,
> James
>
> On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote:
>
>
>
> On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn 
> wrote:
>
> I've been looking at a number of articles on statically linking go files
> by disabling CGO, sounds great except I've got a libsass dependency until
> the native libsass is ready.
>
> Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)?
>
>
> Are you asking about statically linking libsass?
>
> In addition to other flags to statically link your Go binary, you can tell
> cgo to statically link libsass:
>
> $ export CGO_LDFLAGS="\
> -Wl,-Bstatic \
> `pkg-config --libs libsass` \
> -lotherDep -lotherDep2
> -Wl,-Bdynamic"
>
> ​
>
> - Justin
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
>
>
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Statically linking cgo

2016-12-24 Thread James Pettyjohn
Hi Justin,

Thanks for the holiday reply.

The ultimate goal in this was deployment into docker as a self contained 
binary, no dynamic library dependencies and no parent image. The most 
common solution to this I've seen is disable CGO altogether but with the 
libraries I'm using this is not an option at this time.

Best, 
James

On Saturday, December 24, 2016 at 5:36:48 PM UTC-8, Justin Israel wrote:
>
>
>
> On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn  > wrote:
>
>> I've been looking at a number of articles on statically linking go files 
>> by disabling CGO, sounds great except I've got a libsass dependency until 
>> the native libsass is ready.
>>
>> Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)?
>>
>
> Are you asking about statically linking libsass?
>
> In addition to other flags to statically link your Go binary, you can tell 
> cgo to statically link libsass:
>
> $ export CGO_LDFLAGS="\
> -Wl,-Bstatic \
> `pkg-config --libs libsass` \
> -lotherDep -lotherDep2
> -Wl,-Bdynamic"
>
> ​
>
> - Justin
>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Statically linking cgo

2016-12-24 Thread Justin Israel
On Sun, Dec 25, 2016 at 9:22 AM James Pettyjohn 
wrote:

> I've been looking at a number of articles on statically linking go files
> by disabling CGO, sounds great except I've got a libsass dependency until
> the native libsass is ready.
>
> Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)?
>

Are you asking about statically linking libsass?

In addition to other flags to statically link your Go binary, you can tell
cgo to statically link libsass:

$ export CGO_LDFLAGS="\
-Wl,-Bstatic \
`pkg-config --libs libsass` \
-lotherDep -lotherDep2
-Wl,-Bdynamic"

​

- Justin

> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Converting escaped unicode to utf8

2016-12-24 Thread JohnGB
I have an application where I am processing a HTTP request with a JSON 
body.  However, the JSON in the body has been unicode escaped, so instead 
of `wasn't`, I get `wasn\u0027t`.

What is the simplest way to unescape this text back to utf8 encoded text. 
 i.e. convert `wasn\u0027t` to `wasn't`.  Please note that I'm only using 
this as an example, but I'd like all unicode escaped characters to be 
converted to their utf8 equivalents.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread Daniel Skinner
You're right, I failed to consider the constants on Service. I thought I
saw something about this recently but it just turned out to be you five
days ago :)

On Sat, Dec 24, 2016 at 4:27 PM andrey mirtchovski 
wrote:

> Apologies for the digression.
>
>
> This suggests that you still have multiple `app` imports without each
> having a unique name. Double check your imports in all source files being
> compiled.
>
>
> I have renamed both imports to something else and ensured there is nothing
> importing or using "app", however gomobile generates a gomain_bind.go file
> that doesn't take into account the renames:
>
> 
> // File is generated by gobind. Do not edit.
> package gomobile_bind
>
> /*
> #include 
> #include 
> #include "seq.h"
> #include "myapp.h"
>
> */
> import "C"
>
> import (
> "Java/android/app"
> "Java/android/content"
> "Java/android/os"
> "Java/android/support/v7/app"
> "myapp"
> _seq "golang.org/x/mobile/bind/seq"
> )
> 
>
> I think i'll poke around gomobile to try and make
>
>
> > import "Java/android/app/Service"
>
> I'd imagine `Service` is not a package and not something you can import.
> You'd simply access it (whatever *it* is in the bindings) from the `app`
> import.
>
>
> I refer you to the section titled "Importing Java Classes and Interfaces
> from Go" which describes the use of static methods and constants via the
> aforementioned import of an inner class:
> https://github.com/golang/go/issues/16876
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Donating to Go/related causes

2016-12-24 Thread Florin Pățan
Hi there,


I'm happy to hear that there's one more Gopher that would like to help out 
the community. This is exciting!
Here are some of my ideas around this:

- this is where your time is best spent on: 
https://blog.gopheracademy.com/advent-2016/gobridge-beginners/ imho
- or add docs to the stdlib
- or help newbies in this Slack, on the forum, on the ML / Reddit
- or help maintainers identify easy tasks for beginners so that they can 
get contributions in
- or also write more tutorials for beginners to be included in the Tour of 
Go
- or help simplify some of those lessons, add more content to clarify some 
of those exercises (edited) 
- or help on http://exercism.io/languages/go to find if there are any 
issues that can be addressed with the content there, add more exercises 
there, review solutions, help people learning Go using it (edited)
- or help GoBridge get more material for the courses we have

Those are my thoughts on it, hope it helps.
Happy holidays!



Kind regards,
Florin

On Saturday, December 24, 2016 at 4:24:47 PM UTC, Kevin Burke wrote:
>
> Hi,
> I started a software consultancy  in July and I 
> made a fair amount of money this year. A lot of my success was due to the 
> Go programming language/community and I'd like to give back somehow.
>
> As far as I understand, the core Go team and the build environments etc. 
> are sponsored by Google and don't rely on the community for support. 
> Unlike, say, the Python Software Foundation 
> , there's no need or 
> infrastructure to donate to the core language.
>
> So I'm trying to figure out the best place/area to donate. Is there a list 
> somewhere? Some ideas:
>
> - **Donate to new core contributors** - are there any people who would 
> like to do interesting work on the standard library, or could be 
> contributing improvements in a new area, but aren't being paid by Google or 
> their employer and need a sponsor to spend more time on it?
>
> - **Donate to third party libraries in need of support** - Are there 
> critical third party libraries that need upgrading or infrastructure 
> support, or time to build out new features?
>
> - **Donate scholarships** - what's the most cost effective way to help 
> people new to programming, or from a disadvantaged background, get started? 
> To conferences, meetups or to an organization like Hacker School.
>
> - **Donate my time** - Can I provide feature work or code reviews for free 
> to e.g. community, nonprofit or government organizations, writing Go or 
> otherwise?
>
> Apologies if this isn't the best place for this question, but I figure the 
> people who read this email will know the best places to give.
>
> Thanks!
> Kevin
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread andrey mirtchovski
Apologies for the digression.


> This suggests that you still have multiple `app` imports without each
> having a unique name. Double check your imports in all source files being
> compiled.
>

I have renamed both imports to something else and ensured there is nothing
importing or using "app", however gomobile generates a gomain_bind.go file
that doesn't take into account the renames:


// File is generated by gobind. Do not edit.
package gomobile_bind

/*
#include 
#include 
#include "seq.h"
#include "myapp.h"

*/
import "C"

import (
"Java/android/app"
"Java/android/content"
"Java/android/os"
"Java/android/support/v7/app"
"myapp"
_seq "golang.org/x/mobile/bind/seq"
)


I think i'll poke around gomobile to try and make


> > import "Java/android/app/Service"
>
> I'd imagine `Service` is not a package and not something you can import.
> You'd simply access it (whatever *it* is in the bindings) from the `app`
> import.
>
>
I refer you to the section titled "Importing Java Classes and Interfaces
from Go" which describes the use of static methods and constants via the
aforementioned import of an inner class:
https://github.com/golang/go/issues/16876

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: write barrier and C types

2016-12-24 Thread 'Florian Uekermann' via golang-nuts
I just want to leave my solution here, since I am sure I am not the last 
person to run into this.

The issue (as others have suggested and initially assumed) is indeed that 
go expects a pointer where there is none. This only leads to errors when 
the GC scans the stack if I interpret my results correctly.

Fortunately recent versions of vulkan.h allow you to override the define 
like this:
// #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t 
object;
// #include 
import "C"

If you are compiling exclusively for 32bit pointer architectures this is 
not necessary, but won't do any harm either (do it for the sake of 
portability).

I brought this up on the vulkan side of things and found out that this 
seems to be the only way to achieve a strong typedef in some C descendants. 
That big benefit imo justifies the small inconvenience of having to 
override this in some garbage collected languages, so I decided to close 
the issue.

On Sunday, December 18, 2016 at 8:13:39 PM UTC+1, Florian Uekermann wrote:
>
> Well, I am pretty sure I was wrong about something. Turning of the garbage 
> collector results in no error. Any smart ideas for debugging this?
>
> On Sunday, December 18, 2016 at 4:20:25 PM UTC+1, Florian Uekermann wrote:
>>
>> I may be misdiagnosing the problem, but I think go is doing a problematic 
>> check of the value of C pointer types pointers.
>>
>> The following runtime error is reproducible, but does not always happen 
>> in a program:
>>
>> runtime: writebarrierptr *0xc420326a90 = 0x12 
>> fatal error: bad pointer in write barrier
>>
>> The stack trace indicates that the offending line is the last one in the 
>> following snippet:
>>
>> var bi C.VkRenderPassBeginInfo
>> bi.sType = C.VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
>> bi.renderPass = renderpass
>>
>> I checked the address of the .renderPass field and it is indeed 0xc420326a90 
>> and the value
>> of renderpass is 18. As you may have recognized by now, I am using the 
>> vulkan 
>> C bindings.
>> The .renderPass field has type C.VkRenderPass. A quick look at vulkan.h 
>> yields the following:
>>
>> #if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || 
>> defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || 
>> defined(__aarch64__) || defined(__powerpc64__)
>> #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct 
>> object##_T *object;
>> #else
>> #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t 
>> object;
>> #endif
>> ...
>>
>> VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
>>
>>
>> So it seems to me that Vulkan uses a pointer type  on 64bit archs to 
>> store a (potentially non-pointer) handle.
>> Given that structs with these handles are very common, the workaround of 
>> allocating the bi variable on the C heap
>> is a lot of unnecessary work and a bit of a performance issue.
>>
>> I am not quite sure what a writebarrier is in this context, so I am not 
>> sure if deactivating this check creates more issue (GC)?
>>
>> Can someone give some insight into what the long-term options are for go 
>> with respect to this?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread Daniel Skinner
> app redeclared as imported package name

This suggests that you still have multiple `app` imports without each
having a unique name. Double check your imports in all source files being
compiled.

> import "Java/android/app/Service"

I'd imagine `Service` is not a package and not something you can import.
You'd simply access it (whatever *it* is in the bindings) from the `app`
import.

> undefined: "Java/android/support/v7/app".Service

`Service` is under the standard android.app package, not the support lib.
This actually comes full circle to the first error "app redeclared as
imported package name". Double check all source files.

On Sat, Dec 24, 2016 at 11:27 AM andrey mirtchovski 
wrote:

> > I haven't used these bindings but wouldn't you rename the v7 import as
> >
> > sapp "Java/android/support/v7/app"
> >
> > and then import
> >
> > "Java/android/app"
> >
>
>
> I'm still struggling with this. In my case I need v7.app as well as
> android.app and android.app.Service, so my imports are (as per your
> suggestion):
>
> imort (
> ...
>"Java/android/app"
>"Java/android/app/Service"
>sapp "Java/android/support/v7/app"
> ...
> )
>
> but during the build stage I get this error:
>
> #
> _/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:20:
> app redeclared as imported package name
> previous declaration at
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:17
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:31:
> undefined: "Java/android/support/v7/app".Service
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:35:
> undefined: "Java/android/support/v7/app".Service
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:79:
> undefined: "Java/android/support/v7/app".Service
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:83:
> undefined: "Java/android/support/v7/app".Service
>
>
> as far as the current poster's issue, i started looking at it briefly. in
> OnCreate1 I added the following:
>
>
> context := this.GetApplicationContext()
>
> // there are two constructors, one with (Context) and one with
> (Context, int)
> builder := Builder.New1(context)
>
> // there is setMessage(int) and setMessage(CharSequence)
> builder.SetMessage_Ljava_lang_CharSequence_2("Dialog test from go")
>
> this compiles fine, but I get the following error at runtime:
>
> 12-24 10:03:46.407  6969  6969 E art : JNI ERROR (app bug): attempt to
> pass an instance of go.Seq$Ref as argument 1 to void
> android.app.AlertDialog$Builder.(android.content.Context)
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Statically linking cgo

2016-12-24 Thread James Pettyjohn
I've been looking at a number of articles on statically linking go files by 
disabling CGO, sounds great except I've got a libsass dependency until the 
native libsass is ready.

Can this be in a straightforward manner with go 1.6/1.7 on linux (centos)?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread andrey mirtchovski
> I haven't used these bindings but wouldn't you rename the v7 import as
>
> sapp "Java/android/support/v7/app"
>
> and then import
>
> "Java/android/app"
>


I'm still struggling with this. In my case I need v7.app as well as
android.app and android.app.Service, so my imports are (as per your
suggestion):

imort (
...
   "Java/android/app"
   "Java/android/app/Service"
   sapp "Java/android/support/v7/app"
...
)

but during the build stage I get this error:

#
_/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:20:
app redeclared as imported package name
previous declaration at
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:17
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:31:
undefined: "Java/android/support/v7/app".Service
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:35:
undefined: "Java/android/support/v7/app".Service
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:79:
undefined: "Java/android/support/v7/app".Service
/var/folders/sp/06p28g2d0vs7gd2vhf26wl9mgn/T/gomobile-work-395962016/gomobile_bind/go_main.go:83:
undefined: "Java/android/support/v7/app".Service


as far as the current poster's issue, i started looking at it briefly. in
OnCreate1 I added the following:


context := this.GetApplicationContext()

// there are two constructors, one with (Context) and one with
(Context, int)
builder := Builder.New1(context)

// there is setMessage(int) and setMessage(CharSequence)
builder.SetMessage_Ljava_lang_CharSequence_2("Dialog test from go")

this compiles fine, but I get the following error at runtime:

12-24 10:03:46.407  6969  6969 E art : JNI ERROR (app bug): attempt to
pass an instance of go.Seq$Ref as argument 1 to void
android.app.AlertDialog$Builder.(android.content.Context)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread Daniel Skinner
I haven't used these bindings but wouldn't you rename the v7 import as

sapp "Java/android/support/v7/app"

and then import

"Java/android/app"

then reference `app.AlertDialog` as appropriate? You'll also need to call
`dialog.Show()` in `showDialog`.

On Sat, Dec 24, 2016 at 8:35 AM glenford williams <
glenfordwilli...@gmail.com> wrote:

> thanks that worked.
>
> the basic example works but i tried modifying to show a dialog but got
>
>
> error
>
> /home/kingwill101/go/bin/gomobile: loadExportData failed go install -
> pkgdir=/home/kingwill101/go/pkg/gomobile/pkg_android_386 -tags="" -gcflags
> =-shared -ldflags=-shared gitlab.com/kingwill101/reverse/reverse failed:
> exit status 1
> ../reverse/reverse.go:11:2: cannot find package
> "Java/android/app/AlertDialog" in any of:
> /usr/local/go/src/Java/android/app/AlertDialog (from $GOROOT)
> /tmp/gomobile-work-258045397/gen/src/Java/android/app/AlertDialog (
> from $GOPATH)
> /home/kingwill101/go/src/Java/android/app/AlertDialog
>
>
> code
>
>
> package reverse
>
> import (
> "Java/android/databinding/DataBindingUtil"
> "Java/android/os"
> "Java/android/app/AlertDialog"
> "Java/android/support/v7/app"
> rlayout "Java/go/reverse/R/layout"
> "Java/go/reverse/databinding/ActivityMainBinding"
> )
>
> type MainActivity struct {
> app.AppCompatActivity
> }
>
> func (a *MainActivity) OnCreate1(this app.AppCompatActivity, b os.Bundle)
> {
> this.Super().OnCreate1(b)
> db := DataBindingUtil.SetContentView2(this, rlayout.Activity_main)
> mainBind := ActivityMainBinding.Cast(db)
> mainBind.SetAct(this)
> a.showDialog()
> }
>
> func (a *MainActivity) GetLabel() string {
> return "Hello from Go!"
> }
>
> func (a *MainActivity) showDialog(){
> b := AlertDialog().Builder(this.getActivity())
> b.SetMessage("Dialog test from go").SetTitle("GO!!")
> dialog :=b.Create()
> }
>
>
>
>
>
>
> On Saturday, 24 December 2016 04:52:22 UTC-5, Elias Naur wrote:
>
> It seems your gobind command is out of date. Update it and gomobile with
>
> go install golang.org/x/mobile/cmd/...
>
>  - elias
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Donating to Go/related causes

2016-12-24 Thread Kevin Burke
Hi,
I started a software consultancy  in July and I 
made a fair amount of money this year. A lot of my success was due to the 
Go programming language/community and I'd like to give back somehow.

As far as I understand, the core Go team and the build environments etc. 
are sponsored by Google and don't rely on the community for support. 
Unlike, say, the Python Software Foundation 
, there's no need or infrastructure 
to donate to the core language.

So I'm trying to figure out the best place/area to donate. Is there a list 
somewhere? Some ideas:

- **Donate to new core contributors** - are there any people who would like 
to do interesting work on the standard library, or could be contributing 
improvements in a new area, but aren't being paid by Google or their 
employer and need a sponsor to spend more time on it?

- **Donate to third party libraries in need of support** - Are there 
critical third party libraries that need upgrading or infrastructure 
support, or time to build out new features?

- **Donate scholarships** - what's the most cost effective way to help 
people new to programming, or from a disadvantaged background, get started? 
To conferences, meetups or to an organization like Hacker School.

- **Donate my time** - Can I provide feature work or code reviews for free 
to e.g. community, nonprofit or government organizations, writing Go or 
otherwise?

Apologies if this isn't the best place for this question, but I figure the 
people who read this email will know the best places to give.

Thanks!
Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: generic "CRUD" handlers

2016-12-24 Thread Tong Sun
Wow, quite impressive. I wish I had known it earlier. 

One quick question, how does goa support round-robin design? I.e., 
from https://goa.design/learn/guide/ that I quickly peeked, it says

- use goa to generate a complete implementation, including bottle.go
- Then manually edit the bottle.go file

So what would happen if I have edited the bottle.go file, but want to tweak 
my design afterward? 

Thanks

On Tuesday, December 20, 2016 at 7:39:17 PM UTC-5, br...@gophertrain.com 
wrote:
>
> take a look at goa and gorma: https://goa.design
>
> goa generates an API from your description DSL, and Gorma generates the 
> data access layer. It uses gorm under the scenes so you'll have an easy 
> route to migration.
>
> Brian
>
> On Tuesday, December 20, 2016 at 8:46:12 AM UTC-5, Thomas Bellembois wrote:
>>
>> Hello, 
>>
>> I have an application that define structures 
>>
>> type Team struct { 
>>  ID   uint   `gorm:"primary_key"` 
>>  Name string `json:"Name"` 
>> } 
>> type MailingList struct { 
>>  ID   uint   `gorm:"primary_key"` 
>>  Name string `json:"Name"` 
>>  Comment string `json:"Comment"` 
>> } 
>> ... 
>>
>> and handlers to manage CRUD operations 
>>
>> func TeamUpdateHandler(w http.ResponseWriter, r *http.Request) 
>> func TeamCreateHandler(w http.ResponseWriter, r *http.Request) 
>> func TeamDeleteHandler(w http.ResponseWriter, r *http.Request) 
>> func TeamReadHandler(w http.ResponseWriter, r *http.Request) 
>> func MailingListUpdateHandler(w http.ResponseWriter, r *http.Request) 
>> func MailingListCreateHandler(w http.ResponseWriter, r *http.Request) 
>> func MailingListDeleteHandler(w http.ResponseWriter, r *http.Request) 
>> func MailingListReadHandler(w http.ResponseWriter, r *http.Request) 
>>
>> Is there a way in Go to define a CRUD-like model with only 4 generic 
>> handlers to manage this operations ? 
>>
>> Regards, 
>>
>> Thomas 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] To watch connection lost with Go

2016-12-24 Thread Tong Sun
Hi, 

I'm wondering if there is ready-built lib or code that I can use to watch 
for connection lost, e.g., a server failed to response to ping or http 
request, etc. 

I didn't find any, so I'm wondering if it too simple or too hard. 

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread glenford williams
thanks that worked.

the basic example works but i tried modifying to show a dialog but got


error

/home/kingwill101/go/bin/gomobile: loadExportData failed go install -pkgdir=
/home/kingwill101/go/pkg/gomobile/pkg_android_386 -tags="" -gcflags=-shared 
-ldflags=-shared gitlab.com/kingwill101/reverse/reverse failed: exit status 
1
../reverse/reverse.go:11:2: cannot find package 
"Java/android/app/AlertDialog" in any of:
/usr/local/go/src/Java/android/app/AlertDialog (from $GOROOT)
/tmp/gomobile-work-258045397/gen/src/Java/android/app/AlertDialog (from 
$GOPATH)
/home/kingwill101/go/src/Java/android/app/AlertDialog


code


package reverse

import (
"Java/android/databinding/DataBindingUtil"
"Java/android/os"
"Java/android/app/AlertDialog"
"Java/android/support/v7/app"
rlayout "Java/go/reverse/R/layout"
"Java/go/reverse/databinding/ActivityMainBinding"
)

type MainActivity struct {
app.AppCompatActivity
}

func (a *MainActivity) OnCreate1(this app.AppCompatActivity, b os.Bundle) {
this.Super().OnCreate1(b)
db := DataBindingUtil.SetContentView2(this, rlayout.Activity_main)
mainBind := ActivityMainBinding.Cast(db)
mainBind.SetAct(this)
a.showDialog()
}

func (a *MainActivity) GetLabel() string {
return "Hello from Go!"
}

func (a *MainActivity) showDialog(){
b := AlertDialog().Builder(this.getActivity())
b.SetMessage("Dialog test from go").SetTitle("GO!!")
dialog :=b.Create()
}






On Saturday, 24 December 2016 04:52:22 UTC-5, Elias Naur wrote:
>
> It seems your gobind command is out of date. Update it and gomobile with 
>
> go install golang.org/x/mobile/cmd/...
>
>  - elias 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Gomobile: Getting errors when trying to build reverse example

2016-12-24 Thread Elias Naur
It seems your gobind command is out of date. Update it and gomobile with 

go install golang.org/x/mobile/cmd/...

 - elias 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.