[go-nuts] Re: Go package manager

2019-06-03 Thread Yashish Dua
Yes, I just realized my Readme doesn't indicate this. I will update this. Yes, other commands are a sort of wrapper over Go tool commands but it takes care of you few scenarios where a user might have to add flags to Go tool command explicitly. On Saturday, June 1, 2019 at 5:19:51 AM UTC+5:30,

Re: [go-nuts] Avoid global variables in Http handlers

2019-06-03 Thread Aldrin Leal
wrapping into a typedef? typedef MyHandler struct { GlobalThing string } func (h *MyHandler) handle(w http.ResponseWriter, r *http.Request) { } func main() { h := MyHandler{} http.HandleFunc("/", MyHandler.handle) } -- -- Aldrin Leal, / https://ingenieux.io/about/ On Mon, Jun 3, 2019

[go-nuts] Avoid global variables in Http handlers

2019-06-03 Thread Tong Sun
Here is a BAD example (using global variables): var globalThing string func specificHandler(w http.ResponseWriter, r *http.Request) { w.Write(globalConfigThing)} func main() { globalThing = "Hello world!" http.HandleFunc("/something", specificHandler) http.ListenAndServe(":808

[go-nuts] Re: Go 1.8 port to FreeBSD/PowerPC64

2019-06-03 Thread Curtis Hamilton
Currently. the FreeBSD port only supports "i386 amd64 armv6 armv7" and does not support powerpc64 (ppc64). I'm starting with an older version because newer versions seem to only support power8, while I'm using power5. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Go 1.8 port to FreeBSD/PowerPC64

2019-06-03 Thread Curtis Hamilton
I modified the freebsd/amd64 Go code and linux/ppc64 specific assembly code for freebsd/ppc64. With that done, I used the following to cross-compile on freebsd/amd64 host to create the bootstrap: env GOOS=freebsd GOARCH=ppc64 GOROOT_BOOTSTRAP=/usr/local/go ./bootstrap.bash I placed the result

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
The code in utter is essentially the same (I forked it from go-spew), but the output can be used in Go code. Depending on what you want, both are useful. On Mon, 2019-06-03 at 19:44 -0700, 杜沁园 wrote: > go-spew is a really good library, I don not need to write it myself, > Thanks > > 在 2019年6月4日星期

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread 杜沁园
go-spew is a really good library, I don not need to write it myself, Thanks 在 2019年6月4日星期二 UTC+8上午8:19:55,kortschak写道: > > Sorry, missed the go- prefix in Dave's package. > > github.com/davecgh/go-spew > > On Tue, 2019-06-04 at 09:48 +0930, Dan Kortschak wrote: > > There are packages already av

[go-nuts] Connecting to SQL (Postgresql) instance from Go in Google Run, get "database is closed"

2019-06-03 Thread Steve West
Hi, I have a simple Go program in Cloud Run that uses the Postgres SQL driver "github.com/lib/pq" to connect to a Cloud SQL Postgresql instance in the same Google Project. I have enabled the security by setting "Apps in this project: All authorized". The database and the Cloud Run service are i

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
There are packages already available for this. github.com/kortschak/utter (for Go syntax-like printing) github.com/davecgh/spew (for less Go syntax-like printing) On Mon, 2019-06-03 at 08:54 -0700, 杜沁园 wrote: > I recently write a program to recursively print all fields and value > in a  > struc

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
Sorry, missed the go- prefix in Dave's package. github.com/davecgh/go-spew On Tue, 2019-06-04 at 09:48 +0930, Dan Kortschak wrote: > There are packages already available for this. > > github.com/kortschak/utter (for Go syntax-like printing) > github.com/davecgh/spew (for less Go syntax-like print

Re: [go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread Ian Lance Taylor
On Mon, Jun 3, 2019 at 1:59 PM anthony Place wrote: > > there is a 100 or so containing gccgo; '.go','.a','.c', batch and '.html' but > no executable (other than the batch files) > > i was previously hopeful about one called 'gccgo_install.html', but it was > about compilation and then assumed t

Re: [go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread anthony Place
there is a 100 or so containing gccgo; '.go','.a','.c', batch and '.html' but no executable (other than the batch files) i was previously hopeful about one called 'gccgo_install.html', but it was about compilation and then assumed the executable existed. it seems something was not set to make t

Re: [go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread Ian Lance Taylor
On Mon, Jun 3, 2019 at 12:54 PM anthony Place wrote: > > > What does "which gccgo" print? > > which: no gccgo in (/sbin:/bin:/usr/sbin:/usr/bin:/snap/bin) > > i was wondering if i had to add something to the path, or that it wasn't > being packaged, but.. > > * gcc doc says go supported. Yes, Go

Re: [go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread anthony Place
> What does "which gccgo" print? which: no gccgo in (/sbin:/bin:/usr/sbin:/usr/bin:/snap/bin) i was wondering if i had to add something to the path, or that it wasn't being packaged, but.. * gcc doc says go supported. * if i search the fs for gccgo i get all sorts of hits. -- You receive

Re: [go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread Ian Lance Taylor
On Mon, Jun 3, 2019 at 8:48 AM anthony Place wrote: > > i hoped adding -compiler gccgo to go build would just work but... > > > gccgo: exec: "gccgo": executable file not found in $PATH > > i have gcc (8.3) repo. package (solus 5) installed and the docs with it say > it supports go, and there does

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Weiming Shi
Let us have some concrete code snippet for discussion: https://play.golang.org/p/fdcEs3k9U8I Is this what you would like to have? On Mon, Jun 3, 2019 at 11:54 AM 杜沁园 wrote: > I recently write a program to recursively print all fields and value in a > struct. Interface() is the most convinence

[go-nuts] How can I read private field in go struct instance

2019-06-03 Thread 杜沁园
I recently write a program to recursively print all fields and value in a struct. Interface() is the most convinence way to get underlying value in go. But it will panic when field is private.How can I access private field? For simple type, I can stil use Int(),Bool(),etc to read private field.

[go-nuts] [help] trying to use gccgo but missing something

2019-06-03 Thread anthony Place
i hoped adding -compiler gccgo to go build would just work but... > gccgo: exec: "gccgo": executable file not found in $PATH i have gcc (8.3) repo. package (solus 5) installed and the docs with it say it supports go, and there doesn't seem to be anything else about gccgo in the repo. so not rea

[go-nuts] GoGoConf 2019 is coming! [14.06.2019, Kraków, Poland]

2019-06-03 Thread aneta
Dear Go enthusiasts! 2019 GoGoConf edition is coming! We meet in two weeks in Hevre (Kazimierz, Krakow) to listen to great speakers, exchange knowledge and meet other Golang users. We already know the topics of all talks: 🔸Roberto Clapis, Google Tackling contention: the monsters inside the

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
I agree. That is a good point. I consider arrays an edge case. Although still important, it will probably not be all too common. So the extra verbosity should not be a problem. I am happy you generally agree and think these minor tweaks can make a big difference for the roll-out of the propose

[go-nuts] Re: tracking down broken module dependency golint

2019-06-03 Thread t hepudds
For this error: github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing go.mod: unexpected module path "golang.org/x/lint" That is saying 'github.com/golang/lint' was loaded, but the 'go.mod' found at that location for that version had a different module name ('golang.org/x/li

[go-nuts] tracking down broken module dependency golint

2019-06-03 Thread Joseph Lorenzini
Hi all, I've been happily using go modules for several months. A couple days ago, I decided to update my dependencies with go get -u. This failed with: go: github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing go.mod: unexpected module path "golang.org/x/lint" Which led me to: htt

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Michal Strba
'const' could be fine too. I guess this is mostly a matter of personal preference. Regarding the array length syntax. It does require qualifying for two reasons: 1. Unnamed arguments. 2. Using 'gen' (or 'type', 'const') makes it easy to say "gen is not allowed in the return types", which is an im

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
Hi Michal, I would argue that the 'const' keyword would by more correct. Because the array length is and needs to be constant anyway. And it has currently no valid meaning in a parameter list, just like with the 'type' keyword. However i would argue that the array length, if written as part of

[go-nuts] Re: Go 1.8 port to FreeBSD/PowerPC64

2019-06-03 Thread B Carr
I'm wondering what you are trying to do as well. Go (latest version) is already available in the ports collection for FreeBSD. Installs just fine. On Friday, May 31, 2019 at 7:54:55 PM UTC-6, Curtis Hamilton wrote: > > I’m porting Go 1.8 to FreeBSD/PowerPC64. I’ve successfully built > go-Free

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Michal Strba
Hi Martin. The proposal adds types as "values", but not really. You can only accept a type to a function, but you cannot return a type. That makes the system far from a dependent type system, even with the support for generic array lengths. Being able to return types from functions and use those

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
Hi, is my impression correct, that this proposal adds types as values to the language? It's seems like it does the section 'Unnamed generic arguments'. That by itself would go a long way and warrants some discussion, I'd say. If so, then why use a new keyword 'gen'? Why not 'type' itself. It

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Randall O'Reilly
I wrote up a coherent proposal based on the core of the idea below, and added it to the feedback wiki: https://gist.github.com/rcoreilly/bfbee2add03c76ada82810423d81e53d Overall I think it seems quite promising as perhaps the most “Go” version of generics possible, which solves the major use-ca

[go-nuts] Re: ANN: Zstandard Go compression package

2019-06-03 Thread Jimmy Tang
great stuff, not having to lug around the cgo based library that's already there will make deployments easier. On Sunday, 2 June 2019 17:36:46 UTC+1, Klaus Post wrote: > > I am happy to announce the availability of the first Zstandard compressor > written in Go. This package will allow you to ge