[go-nuts] [ANN] aah Go web framework v0.10 Released!

2018-03-28 Thread Jeevanandam M.
Hello All - I'm happy to announce, aah v0.10 have been released. Website: https://aahframework.org Release Notes: https://docs.aahframework.org/v0.10/release-notes.html Your feedback is very valuable. Thanks. Cheers, Jeeva -- You received this message because you are subscribed to the

[go-nuts] Re: Hello World - unexpected NUL in input

2018-03-28 Thread raphael . deem
Hi, Sorry to revive an age old thread, but I'm encountering this error and it seems my files are already utf-8: $ file -I main.go main.go: text/x-c; charset=utf-8 $ file -I cmd/root.go cmd/root.go: text/x-c; charset=utf-8 Is there any programmatic way to detect the messed up character?

Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Randall O'Reilly
I implemented a type registry solution for this situation: https://github.com/rcoreilly/goki/tree/master/ki/kit you just add a one-liner after every struct you want to register, and it builds the map for you — makes it fully modular, etc. Cheers, - Randy > On Mar 28, 2018, at 12:59 PM, Alex

Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Alex Efros
Hi! On Wed, Mar 28, 2018 at 02:13:55PM -0400, Shawn Milochik wrote: > Thanks for the challenge! I found some unused code in the getItem function, > and a way to make it a bit shorter by removing the lookup map. However, > depending on the number of struct types the map may be cleaner for OP. > >

Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Shawn Milochik
Thanks for the challenge! I found some unused code in the getItem function, and a way to make it a bit shorter by removing the lookup map. However, depending on the number of struct types the map may be cleaner for OP. https://play.golang.org/p/ZH09nHsrRoR -- You received this message because

Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Alex Efros
Hi! On Wed, Mar 28, 2018 at 01:38:04PM -0400, Shawn Milochik wrote: > Yes, you can do this. Perhaps someone knows of some kind of cleaner > shortcuts to get there, but this works and is easy to understand without > any magic: > > https://play.golang.org/p/tqon7s2KxTz Here is a bit simplified

Re: [go-nuts] Why is the output different for this program?

2018-03-28 Thread Ian Lance Taylor
On Wed, Mar 28, 2018 at 9:04 AM, Nilsocket wrote: > > package main > > import ( > "fmt" > "unsafe" > ) > > func main() { > showString("12345") > } > > func showString(s string) { > res := *(*[unsafe.Sizeof(s)]byte)(unsafe.Pointer()) > fmt.Println(s, res,

Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Shawn Milochik
Yes, you can do this. Perhaps someone knows of some kind of cleaner shortcuts to get there, but this works and is easy to understand without any magic: https://play.golang.org/p/tqon7s2KxTz -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread thwd
[...] a copy *of* the pointed-to value. On Wednesday, March 28, 2018 at 6:54:53 PM UTC+2, thwd wrote: > > Hi. Don't worry, I do get pointers and pass-by-value. > > I expected the expression (*x) to yield a copy to the pointed-to value. > > But, as you say, that happens on assignment. > > On

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread thwd
Hi. Don't worry, I do get pointers and pass-by-value. I expected the expression (*x) to yield a copy to the pointed-to value. But, as you say, that happens on assignment. On Wednesday, March 28, 2018 at 6:50:06 PM UTC+2, Devon H. O'Dell wrote: > > 2018-03-28 9:39 GMT-07:00 Devon H. O'Dell

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread Devon H. O'Dell
2018-03-28 9:39 GMT-07:00 Devon H. O'Dell : > CopyExplicitDeref gets a pointer to the struct in its receiver. If you > have a pointer to T, then taking a pointer to the dereferenced T is a > no-op: you get the pointer of the thing you just dereferenced. Any > statement

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread Devon H. O'Dell
CopyExplicitDeref gets a pointer to the struct in its receiver. If you have a pointer to T, then taking a pointer to the dereferenced T is a no-op: you get the pointer of the thing you just dereferenced. Any statement &*whatever will always yield the value of whatever. Copy happens on assignment,

Re: [go-nuts] The &(*x) idiom for copying.

2018-03-28 Thread Ian Davis
On Wed, 28 Mar 2018, at 5:21 PM, thwd wrote: > https://play.golang.org/p/pjyoPX99Zr1 > > Taking the address of an explicit dereference has different behavior > than implicitly dereferencing and taking address.> > Is this the desired behavior? It surprised me. I think the naming of your

Re: [go-nuts] Re: Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Jonathan Yu
You can also keep a map between the string form and the reflect.Type to instantiate, something like https://play.golang.org/p/XCfpjQwumkZ However, the Go proverb is true: "Reflection is never clear" https://go-proverbs.github.io/ On Wed, Mar 28, 2018 at 5:58 AM,

[go-nuts] The &(*x) idiom for copying.

2018-03-28 Thread thwd
https://play.golang.org/p/pjyoPX99Zr1 Taking the address of an explicit dereference has different behavior than implicitly dereferencing and taking address. Is this the desired behavior? It surprised me. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Why is the output different for this program?

2018-03-28 Thread Nilsocket
package main import ( "fmt" "unsafe" ) func main() { showString("12345") } func showString(s string) { res := *(*[unsafe.Sizeof(s)]byte)(unsafe.Pointer()) fmt.Println(s, res, []byte(s)) for i := range res { fmt.Printf("%.2x", res[i]) } fmt.Println() }

[go-nuts] Windows cgo complier

2018-03-28 Thread Tamás Gulácsi
gopkg.in/goracle.v2 users report that tdm-gcc64 works for them. -- 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

[go-nuts] cpu profiling in container does not working

2018-03-28 Thread sothy shan
Hello, I am using go application as service in linux docker environment. My application is given 1 cpu when defining docker-compose file. I enabled to cpu profiler within my application. After running my testing, I stop my container and using docker cp, I copied test.prof into local host.

Re: [go-nuts] Windows cgo complier

2018-03-28 Thread Ian Lance Taylor
On Wed, Mar 28, 2018 at 6:17 AM, Luke Mauldin wrote: > Can someone please tell me what the golang team uses as the reference windows > x64 compiler? I have heard references to mingw64 but it would be helpful to > know the exact version they are using for their unit tests

[go-nuts] Windows cgo complier

2018-03-28 Thread Luke Mauldin
Can someone please tell me what the golang team uses as the reference windows x64 compiler? I have heard references to mingw64 but it would be helpful to know the exact version they are using for their unit tests on Windows. I am experiencing different cgo windows behavior in 1.10 than 1.9.3

[go-nuts] Re: Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread gary . willoughby
Thanks. I read that blog post earlier and presents two different ways of handling this. Each maintains a list of switch cases and constants respectively so still not entirely dynamic. I'll probably just go with a switch then. On Wednesday, 28 March 2018 13:25:47 UTC+1, Andrei Tudor Călin

[go-nuts] Re: Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread Andrei Tudor Călin
It isn't really possible to do so because there is no nice and type safe way of getting from a string in the JSON to a Go type, and a value of said type. You must write a little bit of extra code. This article: http://eagain.net/articles/go-dynamic-json/ presents a good approach. On Wednesday,

[go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread gary . willoughby
Is it possible to unmarshall Json by selecting the struct from a field in the Json? I'm porting some PHP code to Go and this is something I may have to approach differently. Here is the Json: [ { "class": "Domain\\Model\\Message", "skus": [ "FOO1" ],

Re: [go-nuts] func or if in many return

2018-03-28 Thread ToSuNuS
Hi Jan, I gave too many fixed values. For this reason I was having trouble. Regards. 28 Mart 2018 Çarşamba 14:32:05 UTC+3 tarihinde Jan Mercl yazdı: > > On Wed, Mar 28, 2018 at 1:20 PM ToSuNuS > wrote: > > > Is there a way to write this more smoothly, or is there no

Re: [go-nuts] func or if in many return

2018-03-28 Thread Jan Mercl
On Wed, Mar 28, 2018 at 1:20 PM ToSuNuS wrote: > Is there a way to write this more smoothly, or is there no problem with the function? Hard to tell. What you've posted seems to not conform to the Go grammar. Please try to share the snippet using the Go playground (

[go-nuts] func or if in many return

2018-03-28 Thread ToSuNuS
Hello friends, I wrote a sample function like this. func OsVersion () string { result: = "some text" if _, err: = os.Stat ("/ etc / redhat_version"); err == nil { sed / s. \ release * / sed / s. \ / * * `) .Output () ) Check (err, "OsVersion does not work.") result: = strings.TrimSpace (string

Re: [go-nuts] A Go Const suggester?

2018-03-28 Thread mrx
Thanks, there seems to be a tool already for most things in Go, just wonderful! Patrik Iselind On Wed, Mar 28, 2018 at 10:54 AM, Ian Davis wrote: > On Wed, 28 Mar 2018, at 8:32 AM, Patrik Iselind wrote: > > Is there such a tool that can go through a GoLang code base and

Re: [go-nuts] A Go Const suggester?

2018-03-28 Thread Ian Davis
On Wed, 28 Mar 2018, at 8:32 AM, Patrik Iselind wrote: > Is there such a tool that can go through a GoLang code base and > suggest values that might be a good idea to convert into constants?> > If a value (for example an int or a string, but excluding values that > are already constants) is hard

[go-nuts] A Go Const suggester?

2018-03-28 Thread Patrik Iselind
Is there such a tool that can go through a GoLang code base and suggest values that might be a good idea to convert into constants? If a value (for example an int or a string, but excluding values that are already constants) is hard coded at least X times in the code base, could be a candidate