[go-nuts] Re: Generate static library written in golang

2017-04-11 Thread hui zhang
I am using go1.8   arm/ darwin not work ,  for both bin and archive .how 
 to solve that

 GOOS=darwin GOARCH=arm GOARM=7  go build -buildmode=c-archive -o libmug.a
> can't load package: package .: no buildable Go source files in 
>
> GOOS=darwin GOARCH=arm  go build -v -o hello.ios main.go
> runtime/internal/sys
> runtime/internal/atomic
> runtime
> math
> command-line-arguments
> # command-line-arguments
> warning: unable to find runtime/cgo.a
> /usr/local/Cellar/go/1.8.1/libexec/pkg/tool/darwin_amd64/link: running 
> clang failed: exit status 1
> ld: warning: ignoring file 
> /var/folders/cp/561_gl9j1wzd8dgv_fn5mk7cgn/T/go-link-691505992/go.o, 
> file was built for armv7 which is not the architecture being linked 
> (x86_64): 
> /var/folders/cp/561_gl9j1wzd8dgv_fn5mk7cgn/T/go-link-691505992/go.o
> Undefined symbols for architecture x86_64:
>   "_main", referenced from:
>  implicit entry/start for main executable
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)


在 2015年6月3日星期三 UTC+8下午8:34:38,Sarim Khan写道:
>
> Hello,
>
> go version go1.4 darwin/amd64
>
> I'm trying to create a static library written in golang, then using that 
> static library in a c/obj/xcode project. 
>
> == gittu.go ==
>
> package gittu
>
> import "C"
>
> //export getGittu
> func getGittu() *C.char {
> s := "Hello Gittu"
> return C.CString(s)
> }
>
> ==
>
> After that i use "go install" to generate a gittu.a in 
> $GOPATH/pkg/darwin_amd64/..
>
> But when i include that gittu.a in xcode, i get this error,
>
> ignoring file /usr/local/Cellar/go/1.4/packages/pkg/darwin_amd64/
> github.com/sarim/gittu.a, file was built for archive which is not the 
> architecture being linked (x86_64)
>
> I manually tried to run cc, but still the same error. Any idea how to 
> generate x86_64 static lib?
>

-- 
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] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
As go support below system ,   what is the difference of   android/386 and
linux/386

are darwin/arm mean  ios ?

can go code compile as c library for android and ios ?

> go tool dist list
> android/386
> android/amd64
> android/arm
> android/arm64
> darwin/386
> darwin/amd64
> darwin/arm
> darwin/arm64
> dragonfly/amd64
> freebsd/386
> freebsd/amd64
> freebsd/arm
> linux/386
> linux/amd64
> linux/arm
> linux/arm64


2017-04-12 9:23 GMT+08:00 hui zhang :

> I am intend to  build go code as c library ,  and link this library in
> other c code .   then integrate in android and ios.
> But I meet errors in the first step  build go code as c library for arm
> darwin
>
>
> 2017-04-12 0:14 GMT+08:00 hui zhang :
>
>> I want to support go on android and ios.
>>
>> package main
>>> import "fmt"
>>> import "C"
>>> //export GoAdder
>>> func GoAdder(x, y int) int {
>>> fmt.Printf("Go says: adding %v and %v\n", x, y)
>>> return x + y
>>> }
>>> //export GetMugenVersion
>>> func GetMugVersion() string {
>>> str := "Go says: version = 1.0"
>>> return str
>>> }
>>> func main() {} // Required but ignored
>>>
>>
>>  this is what I tried on mac os
>>
>> GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1  go build
>>> -buildmode=c-archive -o libmug_ios.a main.go
>>> # runtime/cgo
>>> clang: error: argument unused during compilation: '-mno-thumb'
>>> GOARM=7  GOARCH=arm   go build -buildmode=c-archive -o libmugen_ios.a
>>> can't load package: package .: no buildable Go source files in
>>> /Users/x/Documents/
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/golang-nuts/LDK6T_3Mc4o/unsubscribe.
>> To unsubscribe from this group and all its topics, 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] contexts for busy computations

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 6:09 PM, Alex Flint  wrote:
>
> Suppose I have a long-running computation that I wish to be cancelable via a
> context. By this I mean something that's just churning away on some
> computation, not blocking on a syscall or I/O operation or anything like
> that. Should I just poll ctx.Err() periodically in the inner loop of my
> computation?

Technically you should poll ctx.Done, as ctx.Err is not defined until
the channel returned by ctx.Done is closed.  But see
https://golang.org/issue/19856 .  Anyhow, that aside, yes, poll
periodically.

> Also, can anyone give any insight into approximately how costly
> context.Err() is for the contexts constructed in the context package -- I
> don't want my computation to be dominated by checking for cancellation!

Calling Done (or Err) for a cancellable context will acquire and
release a sync.Mutex.  Other than that they are very cheap.

Note that I wouldn't necessarily poll in the inner loop.  How often to
poll depends on what your program is doing.  For example, if it's a
background computation, then it doesn't matter much if it runs too
long, and polling in the next-to-inner loop would typically be
acceptable.

Ian

-- 
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] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
I am intend to  build go code as c library ,  and link this library in
other c code .   then integrate in android and ios.
But I meet errors in the first step  build go code as c library for arm
darwin


2017-04-12 0:14 GMT+08:00 hui zhang :

> I want to support go on android and ios.
>
> package main
>> import "fmt"
>> import "C"
>> //export GoAdder
>> func GoAdder(x, y int) int {
>> fmt.Printf("Go says: adding %v and %v\n", x, y)
>> return x + y
>> }
>> //export GetMugenVersion
>> func GetMugVersion() string {
>> str := "Go says: version = 1.0"
>> return str
>> }
>> func main() {} // Required but ignored
>>
>
>  this is what I tried on mac os
>
> GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1  go build
>> -buildmode=c-archive -o libmug_ios.a main.go
>> # runtime/cgo
>> clang: error: argument unused during compilation: '-mno-thumb'
>> GOARM=7  GOARCH=arm   go build -buildmode=c-archive -o libmugen_ios.a
>> can't load package: package .: no buildable Go source files in
>> /Users/x/Documents/
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/LDK6T_3Mc4o/unsubscribe.
> To unsubscribe from this group and all its topics, 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] contexts for busy computations

2017-04-11 Thread Alex Flint
Suppose I have a long-running computation that I wish to be cancelable via
a context. By this I mean something that's just churning away on some
computation, not blocking on a syscall or I/O operation or anything like
that. Should I just poll ctx.Err() periodically in the inner loop of my
computation?

Also, can anyone give any insight into approximately how costly
context.Err() is for the contexts constructed in the context package -- I
don't want my computation to be dominated by checking for cancellation!

-- 
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] swig and go

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 5:00 PM, larry104  wrote:
>
> As it seems with go 1.5 there is no 6c compiler anymore - I had it all
> working with go 1.4 but now upgrading to 1.8.1 I'm lost. Does anyone know a
> link to an example how the flow from c++ to an .so  library which I can
> include as package in go (>1.5) works?

If you build using the go tool, everything will continue to work.

If you can't use the go tool to invoke SWIG, then with current Go you
need to invoke SWIG with the -cgo option to get an input file for Go's
cgo tool.  And at that point, it will be much simpler to let the go
tool take over.

Ian

-- 
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] swig and go

2017-04-11 Thread larry104
As it seems with go 1.5 there is no 6c compiler anymore - I had it all 
working with go 1.4 but now upgrading to 1.8.1 I'm lost. Does anyone know a 
link to an example how the flow from c++ to an .so  library which I can 
include as package in go (>1.5) works?

Any help or pointer very much appreciated.
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.


Re: [go-nuts] Is the mem layout the same between go and c?

2017-04-11 Thread 'Axel Wagner' via golang-nuts
TIL :) I should take a look at that, it's a clever way to solve the problem
:)

On Tue, Apr 11, 2017 at 10:02 PM, Ian Lance Taylor  wrote:

> On Tue, Apr 11, 2017 at 10:29 AM, Axel Wagner
>  wrote:
> >
> > This begs the question how syscalls are handled. I assume they don't use
> > cgo, but often they require to pass a pointer to some memory which is
> > documented as a C-struct. Is there any guidance on that (or any problems
> > that might arise there)?
>
> ObPedant: it *raises* the question, it doesn't *beg* the question.
>
> The syscall package (and the golang.org/x/sys/unix package) defines Go
> versions of a number of C structs used by system calls.  Those Go
> versions are generated by cgo (run in a special mode, and with the
> generated files committed to the repository) and are accurate Go
> representations of the C structs.
>
> Ian
>
> > On Tue, Apr 11, 2017 at 6:41 PM, Ian Lance Taylor 
> wrote:
> >>
> >> On Tue, Apr 11, 2017 at 2:25 AM, hui zhang 
> wrote:
> >> >
> >> > If I define the same  2 struct in c and go
> >> > can they be  passed directly with unsafe.Pointer
> >>
> >> The struct layout rules are under-defined in Go.  The current rules
> >> are straightforward, and it is the case that most structs with the
> >> same sequence of field types will look the same in C and Go.  Of
> >> course you must remember that `int` in Go is often not the same size
> >> as `int` in C.  Also the alignment rules are not always the same, so
> >> don't permit any alignment padding.  And this may change in future Go
> >> releases.
> >>
> >> > and how to export go struct from go to c ?
> >>
> >> You can't, not easily.  But it's easy to use cgo to export a C struct
> >> from C to Go, and doing that avoids all the concerns about types and
> >> alignments, so you should do that if at all possible.
> >>
> >>
> >> > /*
> >> > #include 
> >> >
> >> > typedef struct {
> >> > int a;
> >> > int b;
> >> > } Foo;
> >> >
> >> > void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }
> >> >
> >> > */
> >> >
> >> > import "C"
> >> >
> >> > import (
> >> > "fmt"
> >> > "unsafe"
> >> > )
> >> >
> >> > type Foo struct{ a, b int32 }
> >> >
> >> > C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))
> >>
> >> For example, how about `type Foo C.Foo`?
> >>
> >> Ian
> >>
> >> --
> >> 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] Problem compiling go from source code in Alpine Linux powerpc64

2017-04-11 Thread Dave Cheney
A first step to debugging the problem would be to check that cross compiled 
binaries work on your target system. Try something like this.

1. Write helloworld.go
2. env GOOS=linux GOARCH=ppc64le go build helloworld.go
3. scp helloworld to your target host and run it.

If that works, we'll debug the problems with the toolchain from bootstrap.bash

-- 
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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Owen Waller
Sorry I forgot to also ask...

j) Can you tell us which country and educational system you are using?

My material is designed for the UK schools system at what is known as
Upper Key Stage 2 (Ages 10-11).
This will strongly influence what you need to cover and when, in terms
of the pupils ages.

So for example. Functions are not taught in the UK until Upper Key
Stage 3 (About Age 13-14) even though as a programmer you might think
they are pretty vital/easy/obvious :). That's why there is no
discussion about functions in my material. This also removes the need
to teach variable scope, parameters and arguments, return values and
Go's := declaration short-cut operator.

Please note that I am not saying that is correct (or it's how I would
do it, or even that I agree with it, or even that the kids can't master
this earlier) but is is what the UK Gov and therefore UK schools expect
the kids to know at these ages.

The UK Gov's guidelines are here:
https://www.gov.uk/government/publications/national-curriculum-in-engla
nd-computing-programmes-of-study
If you have a equivalent link to the educational system if your country
that would help me give you some more tailored advice.

Owen

On Tue, 2017-04-11 at 19:47 +0100, Owen Waller wrote:
> Hi Bala,
> 
> > Good news, this entirely possible. I've been there done that. My
original post on the subject is here:
> 
> > https://groups.google.com/forum/#!msg/golang-nuts/FIRSDBehb3g/BFiHYVN
CwzUJ
> 
> > So, I can tell you that you can do this with 10/11 year olds and
upwards.
> 
> > It would help enormously if you can us some idea of what your
situation is. Things like:
> 
> a) How old are they
> b) How much time you/they have
> c) Is this in class or after school
> d) Are you taking the class or not
> e) what's your background 
> f) How much the pupils know about programming (and computers)
> g) What environment are you in (Windows/MacOS/Linux)
> h) Do you have control over the PC's or does the school/pupil
> i) How hard do will it be to  Go Dev environment
> 
> > > I'm not currently running any after-school clubs at the minute (due
to other commitments) but some of my teaching material publicly
available at:
> http://gophercoders.com
> and there is some code on github at:
> https://github.com/gophercoders
> 
> > > I have a whole stack more than is currently publicly available. I'm
(very) slowly turning that material into lessons that will eventually
appear on gophercoders.com.
> 
> If I can be of any help just ask.
> 
> Owen
> 
> On Tue, 2017-04-11 at 10:31 -0700, Caleb Spare wrote:
> > I don't think it's off-topic. This ML is about pretty much anything
> > Go-related. We've had discussions about teaching Go to kids before.
> > 
> > On Tue, Apr 11, 2017 at 10:26 AM, Bala Natarajan
> > > >  wrote:
> > > I did not realize that this was off-topic. My mistake.
> > > 
> > > Thanks David and Konstantin for the suggestions
> > > 
> > > Thanks
> > > 
> > > 
> > > > > > On Tuesday, April 11, 2017 at 6:29:21 AM UTC-7, David Peacock
wrote:
> > > > 
> > > > > > > > This is firmly off-topic for this list, but I too am interested
in this
> > > > > > > > area, having recently formed a chapter of CodeClub in my small
town.
> > > > 
> > > > I'd suggest you start at https://www.codeclubworld.org/
> > > > 
> > > > I'm happy to speak with you off-list.
> > > > 
> > > > Good luck!
> > > > 
> > > > Cheers,
> > > > David
> > > > 
> > > > > > > > On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan 
> > > > wrote:
> > > > > 
> > > > > Hi
> > > > > 
> > > > > > > > > > I am trying to put together material to teach go to
elementary/middle
> > > > > > > > > > school kids. Does anyone have public material that I could
use as a guide to
> > > > > > > > > > prepare this material? Any suggestions on small projects 
> > > > > > > > > > that
I could give
> > > > > these kids? Thanks for your suggestions.
> > > > > 
> > > > > Thanks
> > > > > bala
> > > > > 
> > > > > --
> > > > > > > > > > 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/

Re: [go-nuts] Is the mem layout the same between go and c?

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 10:29 AM, Axel Wagner
 wrote:
>
> This begs the question how syscalls are handled. I assume they don't use
> cgo, but often they require to pass a pointer to some memory which is
> documented as a C-struct. Is there any guidance on that (or any problems
> that might arise there)?

ObPedant: it *raises* the question, it doesn't *beg* the question.

The syscall package (and the golang.org/x/sys/unix package) defines Go
versions of a number of C structs used by system calls.  Those Go
versions are generated by cgo (run in a special mode, and with the
generated files committed to the repository) and are accurate Go
representations of the C structs.

Ian

> On Tue, Apr 11, 2017 at 6:41 PM, Ian Lance Taylor  wrote:
>>
>> On Tue, Apr 11, 2017 at 2:25 AM, hui zhang  wrote:
>> >
>> > If I define the same  2 struct in c and go
>> > can they be  passed directly with unsafe.Pointer
>>
>> The struct layout rules are under-defined in Go.  The current rules
>> are straightforward, and it is the case that most structs with the
>> same sequence of field types will look the same in C and Go.  Of
>> course you must remember that `int` in Go is often not the same size
>> as `int` in C.  Also the alignment rules are not always the same, so
>> don't permit any alignment padding.  And this may change in future Go
>> releases.
>>
>> > and how to export go struct from go to c ?
>>
>> You can't, not easily.  But it's easy to use cgo to export a C struct
>> from C to Go, and doing that avoids all the concerns about types and
>> alignments, so you should do that if at all possible.
>>
>>
>> > /*
>> > #include 
>> >
>> > typedef struct {
>> > int a;
>> > int b;
>> > } Foo;
>> >
>> > void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }
>> >
>> > */
>> >
>> > import "C"
>> >
>> > import (
>> > "fmt"
>> > "unsafe"
>> > )
>> >
>> > type Foo struct{ a, b int32 }
>> >
>> > C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))
>>
>> For example, how about `type Foo C.Foo`?
>>
>> Ian
>>
>> --
>> 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] Problem compiling go from source code in Alpine Linux powerpc64

2017-04-11 Thread robertoguimaraes8

I am trying to compile go 1.8 in Alpine Linux ppc64le (that uses musl) but 
I am getting an issue with the generated go (segfault).

As go 1.4 bootstrap does not have support for ppc64le, the steps I did:
1) Installed go 1.4 in an Alpine Linux x86_64
2) Cross compiled go 1.8 ppc64le in the same x86_64
3) Used the tarball with go cross compiled as a bootstrap to compile go in 
ppc64le.

The problem is that the go generated in step 3) is not working and is 
generating a segfault when trying to use it.
I thought that it could be a problem with go 1.8 generated in step 2), but 
the go is working fine and I was able to compile .go files. I also tried to 
use this go as bootstrap in an Ubuntu ppc64le and worked fine too.


I started to debug the go segfault problem and seems that the "argv" and 
"argc" arguments are not correct in Alpine ppc64le, but looks fine in 
x86_64 (see bellow)

- Alpine ppc64le:
#0  runtime.args (c=-1208014796, v=0x0) at 
/home/alpine/go-1.8/go-repo/go/src/runtime/runtime1.go:64
#1  0x00060ecc in runtime.rt0_go () at 
/home/alpine/go-1.8/go-repo/go/src/runtime/asm_ppc64x.s:70

- Alpine x86_64:
#0  runtime.args (c=1, v=0x73028a53f248) at 
/home/rdutra/go-x86/go/src/runtime/runtime1.go:64
#1  0x00453a19 in runtime.rt0_go () at 
/home/rdutra/go-x86/go/src/runtime/asm_amd64.s:156


Any idea of what could be happening?

-- 
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] Diversity Scholarship Applications Open / GopherCon 2017

2017-04-11 Thread Brian Ketelsen
Each year, Gopher Academy donates a sum of money in addition to the funds 
raised by our diversity efforts (like selling Hoodies) towards making GopherCon 
more representative of the developer population as a whole. We strive to help 
people who are traditionally under-represented at technical conferences by 
providing free tickets, lodging, and/or airfare where required. To apply for 
this scholarship, please fill out the following form:

https://docs.google.com/forms/d/e/1FAIpQLSdajMXS1pbgU04hcLThJeJnkcv0ZzvADhiiTaIjITo5VxCITg/viewform

Scholarship Recipients will be notified in May.

Thank you to Sarah Adams who as agreed to help select the scholarship 
recipients this year, and thanks to the companies and individuals who help to 
sponsor our diversity efforts through direct donations and purchase of the 
GopherCon hoodies.  Let’s build on last year’s success and make GopherCon 2017 
the most diverse yet. 

Thank you,

Brian Ketelsen & Erik St. Martin
GopherCon team

-- 
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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Owen Waller
Hi Bala,

Good news, this entirely possible. I've been there done that. My
original post on the subject is here:

https://groups.google.com/forum/#!msg/golang-nuts/FIRSDBehb3g/BFiHYVNCw
zUJ

So, I can tell you that you can do this with 10/11 year olds and
upwards.

It would help enormously if you can us some idea of what your situation
is. Things like:

a) How old are they
b) How much time you/they have
c) Is this in class or after school
d) Are you taking the class or not
e) what's your background 
f) How much the pupils know about programming (and computers)
g) What environment are you in (Windows/MacOS/Linux)
h) Do you have control over the PC's or does the school/pupil
i) How hard do will it be to  Go Dev environment

I'm not currently running any after-school clubs at the minute (due to
other commitments) but some of my teaching material publicly available
at:
http://gophercoders.com
and there is some code on github at:
https://github.com/gophercoders

I have a whole stack more than is currently publicly available. I'm
(very) slowly turning that material into lessons that will eventually
appear on gophercoders.com.

If I can be of any help just ask.

Owen

On Tue, 2017-04-11 at 10:31 -0700, Caleb Spare wrote:
> I don't think it's off-topic. This ML is about pretty much anything
> Go-related. We've had discussions about teaching Go to kids before.
> 
> On Tue, Apr 11, 2017 at 10:26 AM, Bala Natarajan
> >  wrote:
> > I did not realize that this was off-topic. My mistake.
> > 
> > Thanks David and Konstantin for the suggestions
> > 
> > Thanks
> > 
> > 
> > > > On Tuesday, April 11, 2017 at 6:29:21 AM UTC-7, David Peacock
wrote:
> > > 
> > > > > > This is firmly off-topic for this list, but I too am interested
in this
> > > > > > area, having recently formed a chapter of CodeClub in my small
town.
> > > 
> > > I'd suggest you start at https://www.codeclubworld.org/
> > > 
> > > I'm happy to speak with you off-list.
> > > 
> > > Good luck!
> > > 
> > > Cheers,
> > > David
> > > 
> > > > > > On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan 
> > > wrote:
> > > > 
> > > > Hi
> > > > 
> > > > > > > > I am trying to put together material to teach go to
elementary/middle
> > > > > > > > school kids. Does anyone have public material that I could use
as a guide to
> > > > > > > > prepare this material? Any suggestions on small projects that I
could give
> > > > these kids? Thanks for your suggestions.
> > > > 
> > > > Thanks
> > > > bala
> > > > 
> > > > --
> > > > > > > > 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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread David Peacock
Ah, the mistake was my phrasing.

Teaching Go to anyone is not off-topic at all on this Go mailing list. :-)
 I meant my advice surrounding CodeClub was off-topic since it relates to
other languages. :-)

My apologies for the misunderstanding.

On Tue, Apr 11, 2017 at 1:26 PM, Bala Natarajan <
bala.natarajan.p...@gmail.com> wrote:

> I did not realize that this was off-topic. My mistake.
>
> Thanks David and Konstantin for the suggestions
>
> Thanks
>
>
> On Tuesday, April 11, 2017 at 6:29:21 AM UTC-7, David Peacock wrote:
>>
>> This is firmly off-topic for this list, but I too am interested in this
>> area, having recently formed a chapter of CodeClub in my small town.
>>
>> I'd suggest you start at https://www.codeclubworld.org/
>>
>> I'm happy to speak with you off-list.
>>
>> Good luck!
>>
>> Cheers,
>> David
>>
>> On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan 
>> wrote:
>>
>>> Hi
>>>
>>> I am trying to put together material to teach go to elementary/middle
>>> school kids. Does anyone have public material that I could use as a guide
>>> to prepare this material? Any suggestions on small projects that I could
>>> give these kids? Thanks for your suggestions.
>>>
>>> Thanks
>>> bala
>>>
>>> --
>>> 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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Caleb Spare
I don't think it's off-topic. This ML is about pretty much anything
Go-related. We've had discussions about teaching Go to kids before.

On Tue, Apr 11, 2017 at 10:26 AM, Bala Natarajan
 wrote:
> I did not realize that this was off-topic. My mistake.
>
> Thanks David and Konstantin for the suggestions
>
> Thanks
>
>
> On Tuesday, April 11, 2017 at 6:29:21 AM UTC-7, David Peacock wrote:
>>
>> This is firmly off-topic for this list, but I too am interested in this
>> area, having recently formed a chapter of CodeClub in my small town.
>>
>> I'd suggest you start at https://www.codeclubworld.org/
>>
>> I'm happy to speak with you off-list.
>>
>> Good luck!
>>
>> Cheers,
>> David
>>
>> On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan 
>> wrote:
>>>
>>> Hi
>>>
>>> I am trying to put together material to teach go to elementary/middle
>>> school kids. Does anyone have public material that I could use as a guide to
>>> prepare this material? Any suggestions on small projects that I could give
>>> these kids? Thanks for your suggestions.
>>>
>>> Thanks
>>> bala
>>>
>>> --
>>> 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] Is the mem layout the same between go and c?

2017-04-11 Thread 'Axel Wagner' via golang-nuts
This begs the question how syscalls are handled. I assume they don't use
cgo, but often they require to pass a pointer to some memory which is
documented as a C-struct. Is there any guidance on that (or any problems
that might arise there)?

On Tue, Apr 11, 2017 at 6:41 PM, Ian Lance Taylor  wrote:

> On Tue, Apr 11, 2017 at 2:25 AM, hui zhang  wrote:
> >
> > If I define the same  2 struct in c and go
> > can they be  passed directly with unsafe.Pointer
>
> The struct layout rules are under-defined in Go.  The current rules
> are straightforward, and it is the case that most structs with the
> same sequence of field types will look the same in C and Go.  Of
> course you must remember that `int` in Go is often not the same size
> as `int` in C.  Also the alignment rules are not always the same, so
> don't permit any alignment padding.  And this may change in future Go
> releases.
>
> > and how to export go struct from go to c ?
>
> You can't, not easily.  But it's easy to use cgo to export a C struct
> from C to Go, and doing that avoids all the concerns about types and
> alignments, so you should do that if at all possible.
>
>
> > /*
> > #include 
> >
> > typedef struct {
> > int a;
> > int b;
> > } Foo;
> >
> > void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }
> >
> > */
> >
> > import "C"
> >
> > import (
> > "fmt"
> > "unsafe"
> > )
> >
> > type Foo struct{ a, b int32 }
> >
> > C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))
>
> For example, how about `type Foo C.Foo`?
>
> Ian
>
> --
> 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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Bala Natarajan
I did not realize that this was off-topic. My mistake. 

Thanks David and Konstantin for the suggestions 

Thanks


On Tuesday, April 11, 2017 at 6:29:21 AM UTC-7, David Peacock wrote:
>
> This is firmly off-topic for this list, but I too am interested in this 
> area, having recently formed a chapter of CodeClub in my small town.
>
> I'd suggest you start at https://www.codeclubworld.org/
>
> I'm happy to speak with you off-list.
>
> Good luck!
>
> Cheers,
> David
>
> On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan  > wrote:
>
>> Hi
>>
>> I am trying to put together material to teach go to elementary/middle 
>> school kids. Does anyone have public material that I could use as a guide 
>> to prepare this material? Any suggestions on small projects that I could 
>> give these kids? Thanks for your suggestions. 
>>
>> Thanks
>> bala
>>
>> -- 
>> 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.


[go-nuts] Re: Cache or tmp file used by golang compiler?

2017-04-11 Thread timothy . vanheest
I've run into a similar problem a few times.  Each time I ran across this 
article, but each time it was something like the following:

* Compiler says something like: `reindex/reindex.go:367: undefined: 
utils.EsDataTypeMap`
* I check the line, `utils.EsDataTypeMap` is not there.  The line is 
`dataType := converterUtils.EsDataTypeMap[msg.Type]`.
* I try moving the file `reindex/reindex.go ` around, doing all sorts of 
other weird activities to make sure I'm looking at the same file as the 
compiler.
* It turns out I have a line like this in my imports: `converterUtils 
"github.com/rand/thing/utils"`

So the compiler warning *looks* like it's wrong, but it really just ignores 
the import aliasing.

On Wednesday, December 14, 2016 at 7:35:54 AM UTC-5, Onion P wrote:
>
> I found my problem was caused by an unsuccessfully exited process. Thanks 
> for your help anyway.
>
> 在 2016年12月14日星期三 UTC+1上午1:25:48,Dave Cheney写道:
>>
>> Try go install -v, you'll find the program in $GOPATH/bin. If you get no 
>> lines of output, then the program is up to date.
>>
>> On Wednesday, 14 December 2016 11:14:06 UTC+11, ddxgz1...@gmail.com 
>> wrote:
>>>
>>> Hi Uriel,
>>>
>>> How did you solve this problem? Because I'm facing the same.
>>>
>>> 在 2015年8月12日星期三 UTC+2上午10:29:39,Uriel Fanelli写道:


 Hi all

 I am facing a strange behavior in "go build"  process.

 What I am doing is , from time to time, to do a git pull from a github 
 repository and recompile the source
 of a program. (the program is "gogs", https://github.com/gogits/gogs , 
 just for mention).

 What happens to me is that I compile an executable , and the binary is 
 always the same, regardless the source
 code has changed. 

 At the beginning I tried with all favours of "go clean", like "go clean 
 -r" , but the result is the same: after a certain moment,
 dunno why, one machine has continued to produce  an "old" binary, and 
 it was the machine I used to compile the same program in the past.

 Now, my question is: is there any kind of cache, tmp file, whatever the 
 compiler uses, which I could try to clean 
 in order to have a very new executable? This issue is making me crazy, 
 seems this machine is producing always the same
 executable.

 The version of golang I'm using is 1.4.2  64 bit, CC=gcc48

 Uriel





-- 
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: How to set value to empty interface{}

2017-04-11 Thread pierre . curto
Go is a typed language.
I guess it is possible using reflect: 
https://play.golang.org/p/41gguwtlSC but I would steer away from it.


Le mardi 11 avril 2017 18:04:30 UTC+2, Th3x0d3r a écrit :
>
> Not as I expected, but it works,  Would 
> it be possible not to use an specific type (*SomeMessage) an instead use 
> interface{} type in assertion? 
>
> On Tuesday, April 11, 2017 at 9:22:41 AM UTC-4, Th3x0d3r wrote:
>>
>> Hey there !
>>
>> How can i set the value of an interface{} parameter from other 
>> interface{} source
>>
>> Playground : https://play.golang.org/p/utwO2Ru4Eq
>>
>> Output expected:
>>
>> Val 1: &{XML}
>> Val 2: &{XML}
>>
>>
>> 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.


Re: [go-nuts] how to compile a project using govendor with tool name compile ?

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 4:29 AM, Joost Shao  wrote:
>
> how to compile a project using govendor with tool name compile ?
>
> I using command like blow:
>
> go tool compile  -I ./vendor -p ./vendor  -importmap source=./vendor
> main.go
>
> But, it comes out like :
>
> main.go:12: can't find import: "go-package/name1"
>
>
> i tried many times, but still can not find how to compile a project using
> vendor directory to a Object file, like main.o.
>
> Someone can help me ? waiting online , thank you all /// O(∩_∩)O~

Use `go build -x` to see precisely how the go tool passes the
`-importmap` option to `go tool compile`.

Ian

-- 
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] Is the mem layout the same between go and c?

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 2:25 AM, hui zhang  wrote:
>
> If I define the same  2 struct in c and go
> can they be  passed directly with unsafe.Pointer

The struct layout rules are under-defined in Go.  The current rules
are straightforward, and it is the case that most structs with the
same sequence of field types will look the same in C and Go.  Of
course you must remember that `int` in Go is often not the same size
as `int` in C.  Also the alignment rules are not always the same, so
don't permit any alignment padding.  And this may change in future Go
releases.

> and how to export go struct from go to c ?

You can't, not easily.  But it's easy to use cgo to export a C struct
from C to Go, and doing that avoids all the concerns about types and
alignments, so you should do that if at all possible.


> /*
> #include 
>
> typedef struct {
> int a;
> int b;
> } Foo;
>
> void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }
>
> */
>
> import "C"
>
> import (
> "fmt"
> "unsafe"
> )
>
> type Foo struct{ a, b int32 }
>
> C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))

For example, how about `type Foo C.Foo`?

Ian

-- 
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] New free tool JIRA to PDF

2017-04-11 Thread Paulo Coutinho
Hi,

I have made a new tool to export JIRA issues to PDF using a JQL query.

It help us, i think can help anyone.

https://github.com/prsolucoes/jira-to-pdf

-- 
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] What is the best tool today to port (bind) a library of C functions to Go (SWIG)?

2017-04-11 Thread Ian Lance Taylor
On Tue, Apr 11, 2017 at 7:40 AM, Serge Hulne  wrote:
>
> I used SWIG in the past to be able to use C functions from Python code and
> to largely automate the process of making said lib of C functions accessible
> to Python.
>
> I would like to do the same with Go.
>
>
> Is SWIG still the best tool for the job or is there maybe another new too
> more appropriate for the task?

For calling C code most people simply use cgo (https://golang.org/cmd/cgo).

For calling C++ code SWIG is still the best tool for the job.

Ian

-- 
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] how to setup go build arm support for use go on android and ios

2017-04-11 Thread hui zhang
I want to support go on android and ios.

package main
> import "fmt"
> import "C"
> //export GoAdder
> func GoAdder(x, y int) int {
> fmt.Printf("Go says: adding %v and %v\n", x, y)
> return x + y
> }
> //export GetMugenVersion
> func GetMugVersion() string {
> str := "Go says: version = 1.0"
> return str
> }
> func main() {} // Required but ignored
>

 this is what I tried on mac os

GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1  go build -buildmode=c-archive 
> -o libmug_ios.a main.go 
> # runtime/cgo
> clang: error: argument unused during compilation: '-mno-thumb'
> GOARM=7  GOARCH=arm   go build -buildmode=c-archive -o libmugen_ios.a
> can't load package: package .: no buildable Go source files in 
> /Users/x/Documents/
>

-- 
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: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
Not as I expected, but it works,  Would 
it be possible not to use an specific type (*SomeMessage) an instead use 
interface{} type in assertion? 

On Tuesday, April 11, 2017 at 9:22:41 AM UTC-4, Th3x0d3r wrote:
>
> Hey there !
>
> How can i set the value of an interface{} parameter from other interface{} 
> source
>
> Playground : https://play.golang.org/p/utwO2Ru4Eq
>
> Output expected:
>
> Val 1: &{XML}
> Val 2: &{XML}
>
>
> 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: How to set value to empty interface{}

2017-04-11 Thread pierre . curto
In Go, everything is passed by value, including interfaces (empty or not).
A quick overview 
at http://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/.

So, you cannot change the value pointed to by an interface unless you 
"unbox" it: https://play.golang.org/p/uzccweBdzV

Further reading:
to understand interfaces inner workings: 
https://research.swtch.com/interfaces, even though I think that the 
interface value is now always a pointer.


Le mardi 11 avril 2017 16:15:38 UTC+2, Th3x0d3r a écrit :
>
> It works this way, but need to use 
> the GetMessage interface value 
>

-- 
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] What is the best tool today to port (bind) a library of C functions to Go (SWIG)?

2017-04-11 Thread Serge Hulne
Hi,

I used SWIG in the past to be able to use C functions from Python code and 
to largely automate the process of making said lib of C functions 
accessible to Python.

I would like to do the same with Go.


Is SWIG still the best tool for the job or is there maybe another new too 
more appropriate for the task?


Thanks a lot in advance for any advice on the matter.
Serge.

-- 
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: How to set value to empty interface{}

2017-04-11 Thread James Bardin


On Tuesday, April 11, 2017 at 10:10:25 AM UTC-4, Th3x0d3r wrote:
>
> AFAIK empty interfaces{} are passed by reference
>
>
Nothing in go is "pass by reference". The interface value is always copied. 

-- 
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: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
It works this way, but need to use 
the GetMessage interface value 

-- 
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: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
I would but need to use empty interfaces{} as parameters

On Tuesday, April 11, 2017 at 9:52:20 AM UTC-4, Pierre Curto wrote:
>
> Either pass around the pointer to your struct or use a dedicated interface 
> to alter the struct contents.
> Examples of each here  and there 
> .
>
> Le mardi 11 avril 2017 15:22:41 UTC+2, Th3x0d3r a écrit :
>>
>> Hey there !
>>
>> How can i set the value of an interface{} parameter from other 
>> interface{} source
>>
>> Playground : https://play.golang.org/p/utwO2Ru4Eq
>>
>> Output expected:
>>
>> Val 1: &{XML}
>> Val 2: &{XML}
>>
>>
>> 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: How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
AFAIK empty interfaces{} are passed by reference

On Tuesday, April 11, 2017 at 9:46:00 AM UTC-4, T L wrote:
>
>
>
> On Tuesday, April 11, 2017 at 9:22:41 PM UTC+8, Th3x0d3r wrote:
>>
>> Hey there !
>>
>> How can i set the value of an interface{} parameter from other 
>> interface{} source
>>
>> Playground : https://play.golang.org/p/utwO2Ru4Eq
>>
>> Output expected:
>>
>> Val 1: &{XML}
>> Val 2: &{XML}
>>
>>
>> Thanks 
>>
>
>
> func GetClient(method string, resp interface{}) error {
> result := GetMessage("XML")
> resp = result
> fmt.Printf("Val 1: %v\n", resp)
> return nil
> }
>
> resp is an input parameter, when you pass a value as this parameter into 
> the GetClient function, 
> it is copied into the call in fact.
> Modifications on this copy will not be reflected to the original value 
> outside of the called function.
>
> If you do want to make the modifications visible to caller, you can return 
> it as an output result, or use a pointer parameter instead.
>
>  
>

-- 
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: How to set value to empty interface{}

2017-04-11 Thread pierre . curto
Either pass around the pointer to your struct or use a dedicated interface 
to alter the struct contents.
Examples of each here  and there 
.

Le mardi 11 avril 2017 15:22:41 UTC+2, Th3x0d3r a écrit :
>
> Hey there !
>
> How can i set the value of an interface{} parameter from other interface{} 
> source
>
> Playground : https://play.golang.org/p/utwO2Ru4Eq
>
> Output expected:
>
> Val 1: &{XML}
> Val 2: &{XML}
>
>
> 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: How to set value to empty interface{}

2017-04-11 Thread T L


On Tuesday, April 11, 2017 at 9:22:41 PM UTC+8, Th3x0d3r wrote:
>
> Hey there !
>
> How can i set the value of an interface{} parameter from other interface{} 
> source
>
> Playground : https://play.golang.org/p/utwO2Ru4Eq
>
> Output expected:
>
> Val 1: &{XML}
> Val 2: &{XML}
>
>
> Thanks 
>


func GetClient(method string, resp interface{}) error {
result := GetMessage("XML")
resp = result
fmt.Printf("Val 1: %v\n", resp)
return nil
}

resp is an input parameter, when you pass a value as this parameter into 
the GetClient function, 
it is copied into the call in fact.
Modifications on this copy will not be reflected to the original value 
outside of the called function.

If you do want to make the modifications visible to caller, you can return 
it as an output result, or use a pointer parameter instead.

 

-- 
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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread David Peacock
This is firmly off-topic for this list, but I too am interested in this
area, having recently formed a chapter of CodeClub in my small town.

I'd suggest you start at https://www.codeclubworld.org/

I'm happy to speak with you off-list.

Good luck!

Cheers,
David

On Tue, Apr 11, 2017 at 8:24 AM, Bala Natarajan <
bala.natarajan.p...@gmail.com> wrote:

> Hi
>
> I am trying to put together material to teach go to elementary/middle
> school kids. Does anyone have public material that I could use as a guide
> to prepare this material? Any suggestions on small projects that I could
> give these kids? Thanks for your suggestions.
>
> Thanks
> bala
>
> --
> 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] How to set value to empty interface{}

2017-04-11 Thread Th3x0d3r
Hey there !

How can i set the value of an interface{} parameter from other interface{} 
source

Playground : https://play.golang.org/p/utwO2Ru4Eq

Output expected:

Val 1: &{XML}
Val 2: &{XML}


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.


Re: [go-nuts] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Konstantin Khomoutov
On Tue, 11 Apr 2017 05:24:46 -0700 (PDT)
Bala Natarajan  wrote:

> I am trying to put together material to teach go to elementary/middle 
> school kids. Does anyone have public material that I could use as a
> guide to prepare this material? Any suggestions on small projects
> that I could give these kids? Thanks for your suggestions.

"An Introduction to Programming in Go"
Copyright © 2012 by Caleb Doxsey
ISBN: 978-1478355823

Which is freely available in PDF form from [1] is the closest thing I
can think of.  IMO it provides a pretty gentle introduction and is
specifically targetted at novice programmers.

1. https://www.golang-book.com/books/intro

-- 
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] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Bala Natarajan
Hi

I am trying to put together material to teach go to elementary/middle 
school kids. Does anyone have public material that I could use as a guide 
to prepare this material? Any suggestions on small projects that I could 
give these kids? Thanks for your suggestions. 

Thanks
bala

-- 
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] how to compile a project using govendor with tool name compile ?

2017-04-11 Thread Joost Shao
hi, guys.


how to compile a project using govendor with tool name compile ?

I using command like blow:

go tool compile  -I ./vendor -p ./vendor  -importmap source=./vendor  main.
go

But, it comes out like :

main.go:12: can't find import: "go-package/name1"


i tried many times, but still can not find how to compile a project using 
vendor directory to a Object file, like main.o.

Someone can help me ? waiting online , thank you all /// O(∩_∩)O~

-- 
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: Can the bit representation of a float64 silently change?

2017-04-11 Thread Manlio Perillo
Il giorno lunedì 10 aprile 2017 16:53:31 UTC+2, 
brian@robustperception.io ha scritto:
>
> Hi,
>
> I'm working on a feature for the Prometheus monitoring system that 
> requires adding special entries in our database.
> Our values are float64, and I plan on taking advantage of the fact that 
> there's 2^52-1 valid bit representations for NaN.
> So I'll choose one of those representations for an actual NaN (as we 
> support that), and others for the special entries I need.
>
> What I'd like to do is change the few bits of code that need to know about 
> the special values, and continue to use float64 types as-is elsewhere.
>
> I worry though that with the complexity of modern systems that depending 
> on the bit representation of a NaN not to change as a float64 is passed 
> around may not be wise.
> Not having to change everything to [8]byte throughout the stack would be 
> handy, but I am willing to switch all the relevant code if needed.
>
> What I'm wondering is:
> 1) Is it safe to presume Go itself won't change the bit representation of 
> a NaN?
>

The representation of NaN is not decided by Go, but by the IEEE 
754 standard.
You can see some details in
https://golang.org/src/math/bits.go
https://en.wikipedia.org/wiki/NaN#Encoding

Currently the NaN value as returned by math.NaN function is encoded as
0x7FF80001.  But you can use any other values, and compare them 
using the
Float64bits function.

2) It is safe to presume FPUs won't change the bit representation of a NaN?
>

What do you plan to do with these "placeholder" values?
If you just store them in memory and compare them, then, AFAIK, they will 
not be modified.

> [...]

Manlio

-- 
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] Can the bit representation of a float64 silently change?

2017-04-11 Thread Brian Brazil
On 10 April 2017 at 17:38, Michael Jones  wrote:

> It is not crazy in any way to use the special NaN payload--it was designed
> just for you. Dr. Kahan and others provided the broad set of NaNs in '754
> for just this purpose, for example, to encode missing data values and N/A
> data values separately for statistical processing, or to allow great
> freedom to encode provenance or intent in the lower bits.
>

Great, thanks for the information.


>
> One reservation is that FP operations with quiet NaNs and signalling NaNs
> are not inherently full speed, so benchmark to make sure you are satisfied
> about performance in your specific context.
>

At the level we care about it's all bit twiddling (e.g. XOR-based
compression), so this shouldn't affect us. It'll all be benchmarked anyway.

Yours,
Brian


>
> On Mon, Apr 10, 2017 at 7:27 AM,  wrote:
>
>> Hi,
>>
>> I'm working on a feature for the Prometheus monitoring system that
>> requires adding special entries in our database.
>> Our values are float64, and I plan on taking advantage of the fact that
>> there's 2^52-1 valid bit representations for NaN.
>> So I'll choose one of those representations for an actual NaN (as we
>> support that), and others for the special entries I need.
>>
>> What I'd like to do is change the few bits of code that need to know
>> about the special values, and continue to use float64 types as-is elsewhere.
>>
>> I worry though that with the complexity of modern systems that depending
>> on the bit representation of a NaN not to change as a float64 is passed
>> around may not be wise.
>> Not having to change everything to [8]byte throughout the stack would be
>> handy, but I am willing to switch all the relevant code if needed.
>>
>> What I'm wondering is:
>> 1) Is it safe to presume Go itself won't change the bit representation of
>> a NaN?
>> 2) It is safe to presume FPUs won't change the bit representation of a
>> NaN?
>> 3) If 1) and not 2), is there a way control/know when a float64 could
>> have ended up in a FPU? At the level where it matters, we're almost
>> entirely doing bit manipulation rather than floating point operations.
>>
>> As this is a mildly crazy idea, I've unfortunately not been able to find
>> any documentation indicating one way or other.
>>
>> Thanks,
>> Brian
>>
>> --
>> 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.
>>
>
>
>
> --
> Michael T. Jones
> michael.jo...@gmail.com
>



-- 
Brian Brazil
www.robustperception.io

-- 
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] How to distinguish a interface{} from a real type value?

2017-04-11 Thread Jakob Borg
The int gets boxed into an interface{} as part of the function call, making it 
equivalent to the other interface{} passed. However:

https://play.golang.org/p/uxFkrMa_cD

> On 11 Apr 2017, at 11:32, xjdrew  wrote:
> 
> package main
> 
> import (
>   "reflect"
> )
> 
> func main() {
>   var a interface{}
>   a = 5
>   b := 5
>   
>   println(a == b)
>   println(reflect.TypeOf(a) == reflect.TypeOf(b))
> }
> 
> As the above code show, a is a interface{} associated with a int value, b is 
> int, how can I point out the difference of their type?
> 
> play ground: https://play.golang.org/p/hpbHWLjnms
> 
> 
> -- 
> 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] How to distinguish a interface{} from a real type value?

2017-04-11 Thread xjdrew
package main

import (
"reflect"
)

func main() {
var a interface{}
a = 5
b := 5
println(a == b)
println(reflect.TypeOf(a) == reflect.TypeOf(b))
}

As the above code show, a is a interface{} associated with a int value, b 
is int, how can I point out the difference of their type?

play ground: https://play.golang.org/p/hpbHWLjnms

-- 
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] what happens with this code so the client does not get disconnected ?

2017-04-11 Thread mhhcbon
hi,

about https://play.golang.org/p/3S-C4BhNYa

a q&d tcp server that echoes back the inputs.
it can understand few specific words such as new, kill, start, done.

so one can do

nc localhost 8080
kill
start
new

to stop the remote server, restart it, open a new client.

Which is unexpected, 
the first client connected (command&control)  should have been disconnected 
after the kill command,
but it is still there.
Also, golang does not complain when the server closes/re opens,
there are no error messages about a busy port.
And new clients can connect.

It is a great behavior, makes me think to socket_reuse, with proper error 
management,
but it makes me wonder 
what happens behind the scene ?
will there be a background timeout operation that will panic soon ?
or any other flaws?

I m also interested by a quick CR about it, if you agree to take a minute.

-- 
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] Is the mem layout the same between go and c?

2017-04-11 Thread hui zhang
If I define the same  2 struct in c and go
can they be  passed directly with unsafe.Pointer
and how to export go struct from go to c ?   

/*
#include 

typedef struct {
int a;
int b;
} Foo;

void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }

*/

import "C"
import (
"fmt"
"unsafe")

type Foo struct{ a, b int32 }

C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))

-- 
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 a program for Linux in Go lang which can run any command (of coder's choice) on another machine (privately or publicly accessible) and prints its output.

2017-04-11 Thread paraiso . marc
sounds like homework that should be done by the student, not the community. 

Le mardi 11 avril 2017 00:42:32 UTC+2, Owais Hashmi a écrit :
>
> Write a program for Linux in Go lang which can run any command (of coder's 
> choice) on another machine (privately or publicly accessible) and prints 
> its output.
>

-- 
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.