Re: [go-nuts] []byte to func

2017-03-20 Thread Basile Starynkevitch
On Tuesday, March 21, 2017 at 4:04:34 AM UTC+1, Rob 'Commander' Pike wrote: > > No, Go does not have run-time evaluation of Go program source. It is > strictly a compiled language, although there are some (pieces of) > interpreters out there. > > > However, Go 1.8 has plugins

Re: [go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Thanks Harley. I will pick your example and will see if this is do-able... Sandeep Best Regards, Sandeep Kalra On Mon, Mar 20, 2017 at 11:48 PM, Harley Laue wrote: > I have some code that I've sat on for some time: > > type Cell int > type Function func() error

[go-nuts] Re: Unmarshalling JSON from MongoDB serverStatus in Go - how to handle nesting, and easy retrieval?

2017-03-20 Thread kumargv
hi , I am also having the same problem, can you please elaborate invalid operation: dat["connections"]["current"] (type interface {} does not support indexing) Thanks On Friday, August 21, 2015 at 4:22:22 PM UTC+5:30, Giulio Iotti wrote: > > On Friday, August 21, 2015 at 11:51:32 AM UTC+2,

Re: [go-nuts] []byte to func

2017-03-20 Thread Harley Laue
I have some code that I've sat on for some time: type Cell int type Function func() error func cellToFunction(c Cell) *Function { p := unsafe.Pointer(uintptr(c)) if p == nil { return nil } return (*Function)(p) } func functionToCell(w *Function) Cell { return

Re: [go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Thanks Rob! On Monday, March 20, 2017 at 10:04:34 PM UTC-5, Rob 'Commander' Pike wrote: > > No, Go does not have run-time evaluation of Go program source. It is > strictly a compiled language, although there are some (pieces of) > interpreters out there. > > -rob > > > On Mon, Mar 20, 2017 at

Re: [go-nuts] []byte to func

2017-03-20 Thread Rob Pike
No, Go does not have run-time evaluation of Go program source. It is strictly a compiled language, although there are some (pieces of) interpreters out there. -rob On Mon, Mar 20, 2017 at 7:57 PM, Sandeep Kalra wrote: > Is there any option to convert []byte to func

[go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Is there any option to convert []byte to func (Assuming that []byte carries valid function) package main import ( "fmt" "io/ioutil" ) func run(b []byte) { /// HERE ? } func main() { if b, e := ioutil.ReadFile("./file.go"); e != nil { fmt.Println(e) } else {

Re: [go-nuts] Inspecting a function for its arguments with reflection

2017-03-20 Thread Marian Kopriva
Check out https://github.com/go-martini/martini if you're looking for some magic. In case you don't find any magic there, then i'm sorry, i've havne't used martini myself, and am not familiar with its source, i've only heard from others that it's quite magicky. -- You received this message

[go-nuts] Re: Inspecting a function for its arguments with reflection

2017-03-20 Thread Marian Kopriva
What you're looking for is reflect.Type.NumIn()int and reflect.Type.In(i int) Type. See example here https://play.golang.org/p/q1D56Abj-5 On Tuesday, March 21, 2017 at 12:01:09 AM UTC+1, Tyler Compton wrote: > > I'm trying to create an HTTP request router library that automatically > decodes

Re: [go-nuts] import/link problems with gccgo

2017-03-20 Thread Richard D'Addio
Ok thanks I saw that post but didn't read down far enough, I am using golang v1.8 and GCC-7.0 and most of the refs in that post were golang v1.6 and GCC-6.x. At the tail end there was some refs to golang v1.7 as you say. Issue has been around for almost a year I guess. Ended up switching to

[go-nuts] Puzzled by a profiling result around allocations

2017-03-20 Thread Harry B
Hi, As part of preparing an internal go talk to explain using strings vs bytes of the bufio.Scanner, I created two small samples https://play.golang.org/p/-TYycdHaPC and https://play.golang.org/p/L7W-jiaHdL , the only difference in the hot path is reducing the conversions from `[]byte` to

Re: [go-nuts] atomic bugs

2017-03-20 Thread Ian Lance Taylor
On Sat, Mar 18, 2017 at 12:03 PM, T L wrote: > > At the end of sync/atomic package docs, it says > > On x86-32, the 64-bit functions use instructions unavailable before the > Pentium MMX. > > > On non-Linux ARM, the 64-bit functions use instructions unavailable before > the

Re: [go-nuts] import/link problems with gccgo

2017-03-20 Thread Ian Lance Taylor
On Mon, Mar 20, 2017 at 4:25 PM, Ian Lance Taylor wrote: > On Mon, Mar 20, 2017 at 4:17 PM, Richard D'Addio wrote: >> With gccgo I get the following error the same builds fine with gc: >> >> //with native >> >>

Re: [go-nuts] import/link problems with gccgo

2017-03-20 Thread Ian Lance Taylor
On Mon, Mar 20, 2017 at 4:17 PM, Richard D'Addio wrote: > With gccgo I get the following error the same builds fine with gc: > > //with native > > /home/rdaddio/mynewclient/clone_gobotics/gobotics/go/pkg/tool/linux_amd64/compile > -o $WORK/github.com/hashicorp/go-multierror.a

Re: [go-nuts] Why were tabs chosen for indentation?

2017-03-20 Thread Dan Kortschak
On Mon, 2017-03-20 at 09:45 +0100, 'Axel Wagner' via golang-nuts wrote: > The "philosophy of gofmt" was to end arguments about how go code > should be formatted. > Which gives this thread a special form of irony :) People will always adjust their behaviour to minimise the delta on their

Re: [go-nuts] import/link problems with gccgo

2017-03-20 Thread Richard D'Addio
With gccgo I get the following error the same builds fine with gc: *//with native* /home/rdaddio/mynewclient/clone_gobotics/gobotics/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/hashicorp/go-multierror.a -trimpath $WORK -p github.com/hashicorp/go-multierror -complete -buildid

Re: [go-nuts] Only build go binary from source

2017-03-20 Thread Ian Lance Taylor
On Sun, Mar 19, 2017 at 3:29 PM, wrote: > > I am tinkering with some runtime code and I would like to build only the go > binary to the test it on a small program I wrote. I don't see any script in > the source that would allow that, all of these also try to compile the >

Re: [go-nuts] Inspecting a function for its arguments with reflection

2017-03-20 Thread Tyler Compton
Also, if there already exists a library that does this kind of magic for REST APIs, I'd love to hear about it. On Mon, Mar 20, 2017 at 4:01 PM Tyler Compton wrote: > I'm trying to create an HTTP request router library that automatically > decodes parameters in the request URL

Re: [go-nuts] How to control the symbol visibility of shared lib built from Go

2017-03-20 Thread Ian Lance Taylor
On Mon, Mar 20, 2017 at 4:51 AM, Song Liu wrote: > > I am going to write a shared library using the Go, you know that the Go > runtime and used libraries are compiled into the library together. > > But it seems that all the symbols from this library is "DEFAULT", is there a >

[go-nuts] Inspecting a function for its arguments with reflection

2017-03-20 Thread Tyler Compton
I'm trying to create an HTTP request router library that automatically decodes parameters in the request URL and passes them as arguments to the handler function. It would theoretically make something like this possible: myRouter.HandleFunc("/getPuppies/{id}", func(w http.ResponseWriter, r

[go-nuts] import/link problems with gccgo

2017-03-20 Thread Richard D'Addio
Sorry in advance if this is the wrong list for this. I can build the gobot.io code below with the golang v1.8 and the standard compiler: go version go1.8 linux/amd64 go build -work -x hello_blink.go But when I try to build with the GCC option in the same scenario it fails. I am using

[go-nuts] [ANN] go-resty v0.11 release - simple HTTP and REST client library

2017-03-20 Thread jeeva . tkm
Stable Version : gopkg.in/resty.v0 Edge Version : https://github.com/go-resty/resty godoc : https://godoc.org/github.com/go-resty/resty *This release brings following:* *Releases Notes:* https://github.com/go-resty/resty/releases/latest *Feature:* - Request based on SRV record

[go-nuts] Extracting ssh public key from private key file using go

2017-03-20 Thread even . simon
I'm using this method to extract and get the public key string from an original ssh private key. They key ends up to be broken/badly formatted. I've checked it against the key generated by ssh-keygen and the first few chars are different. Anyone has any ideas? func ExtractPublicKey(der []byte)

[go-nuts] Best way to save users input data that could be used later?

2017-03-20 Thread Paulius Daubaris
Hello, I am writing this application, where I can store some reminders for myself in CLI to not forget something important. My question is how can I save my input data or lets say what's the best way to do so? I've tried JSON, but it didnt work out, primarily because I cant really figure it

[go-nuts] [ANN] go-resty v0.11 release - simple HTTP and REST client library

2017-03-20 Thread Jeevanandam M.
Stable Version : gopkg.in/resty.v0 Edge Version : https://github.com/go-resty/resty godoc : https://godoc.org/github.com/go-resty/resty *This release brings following:* *Releases Notes:* https://github.com/go-resty/resty/releases/latest *Feature:* - Request based on SRV record

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
T L, For example: https://play.golang.org/p/BSwB8jQwBY Peter On Monday, March 20, 2017 at 1:24:46 PM UTC-4, peterGo wrote: > > s/strcts/structs/ > > On Monday, March 20, 2017 at 1:24:06 PM UTC-4, peterGo wrote: >> >> TL, >> >> https://golang.org/ref/spec#Size_and_alignment_guarantees >> >> For

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
s/strcts/structs/ On Monday, March 20, 2017 at 1:24:06 PM UTC-4, peterGo wrote: > > TL, > > https://golang.org/ref/spec#Size_and_alignment_guarantees > > For eample, some strcts. > > Peter > > On Monday, March 20, 2017 at 11:23:02 AM UTC-4, T L wrote: >> >> Or if the first element in an array is

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
TL, https://golang.org/ref/spec#Size_and_alignment_guarantees For eample, some strcts. Peter On Monday, March 20, 2017 at 11:23:02 AM UTC-4, T L wrote: > > Or if the first element in an array is 64bit aligned and the size of array > elements is 8N bytes, > is it for sure that all elements in

[go-nuts] Re: togo: tool for converting files to .go

2017-03-20 Thread Zellyn
https://github.com/jteeuwen/go-bindata is the one I see most often. There are several alternatives listed in the README at https://github.com/shurcooL/vfsgen On Monday, March 20, 2017 at 12:02:47 PM UTC-4, Francesco Lazzarino wrote: > > Hi, > > I made a handy tool that converts a file in a pkgs

[go-nuts] togo: tool for converting files to .go

2017-03-20 Thread Francesco Lazzarino
Hi, I made a handy tool that converts a file in a pkgs to a src file with a []byte var. Then you can compile arbitrary files into a pkg. I found it handy for use via go generate. https://github.com/flazz/togo If this is a solved problem (or a bad approach) let me know, I'll amend the README

[go-nuts] a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread T L
Or if the first element in an array is 64bit aligned and the size of array elements is 8N bytes, is it for sure that all elements in the array are 64bit aligned? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

[go-nuts] Mocking Practice

2017-03-20 Thread Jamie Stackhouse
I have an implementation of a storage interface for github.com/RangelReale/osin that I would like to be able to test each function in isolation. One of the aspects of the interface is that certain functions must return with data loaded that other functions are responsible for returning in the

Re: [go-nuts] How to return a Go struct to C

2017-03-20 Thread Steven Hartland
The following may help: http://feisky.xyz/2016/04/19/cgo-in-go-1-6/ On 20/03/2017 13:25, Song Liu wrote: Hi, I have a shared lib as bellow: | /* #include structMedia{ char*Name; char*Path; uint64_tSize; }; */ import"C" //exportGetMediaFromDB funcGetMediaFromDB(filename*C.char)*C.struct_Media{

[go-nuts] How to return a Go struct to C

2017-03-20 Thread Song Liu
Hi, I have a shared lib as bellow: /* #include struct Media { char*Name; char*Path; uint64_t Size; }; */ import "C" //export GetMediaFromDB func GetMediaFromDB(filename *C.char) *C.struct_Media { c_struct_media := _Media{} return c_struct_media }

[go-nuts] How to control the symbol visibility of shared lib built from Go

2017-03-20 Thread Song Liu
Hi, I am going to write a shared library using the Go, you know that the Go runtime and used libraries are compiled into the library together. But it seems that all the symbols from this library is "DEFAULT", is there a way to use the "HIDDEN" symbol visibility by default, but "DEFAULT" only

Re: [go-nuts] How to accept any function with one return value as a parameter

2017-03-20 Thread Konstantin Khomoutov
On Sun, 19 Mar 2017 13:51:05 -0700 (PDT) aktungmak wrote: > I am trying to write a function that initializes a generic > collection. For adding new items to the collection, the user > specifies a constructor which takes one argument and returns a > pointer to the struct that

Re: [go-nuts] Why were tabs chosen for indentation?

2017-03-20 Thread 'Axel Wagner' via golang-nuts
The "philosophy of gofmt" was to end arguments about how go code should be formatted. Which gives this thread a special form of irony :) On Mon, Mar 20, 2017 at 1:59 AM, Wojciech S. Czarnecki wrote: > > > > On Sun, 19 Mar 2017, at 09:35 PM, Rob Pike wrote: > > > everyone will

[go-nuts] plugins (Go 1.8) and packages

2017-03-20 Thread Basile Starynkevitch
Hello all, Here are some thoughts and questions about plugins in Go 1.8 (which I use on Linux/x86-64). *Plugins in other languages* In C and C++ code (on Linux), plugins are practically not exactly the same as e.g. shared objects (a good reference would be Drepper's *How To Write Shared