[go-nuts] Re: const type deduction

2017-03-21 Thread Dave Cheney
fmt is outputting an error because you passed it an integer type when you asked it to format a boolean type. I think you wanted %T, not %t https://play.golang.org/p/Uvws_k2peX On Wednesday, 22 March 2017 12:23:04 UTC+11, WinD zz wrote: > > > func main() { > const abc = 111 >

Re: [go-nuts] const type deduction

2017-03-21 Thread Ian Lance Taylor
On Tue, Mar 21, 2017 at 5:38 PM, WinD zz wrote: > > func main() { > const abc = 111 > fmt.Printf("%t\n", abc) > fmt.Println(math.Pi * abc) > fmt.Printf("%t", math.Pi) > } > > result: > %!t(int=111) > 25.132741228718345 > %!t(float64=3.141592653589793) > > func main() { >

Re: [go-nuts] Discussion on moving projects from syscall to sys/[platform]

2017-03-21 Thread Ian Lance Taylor
On Tue, Mar 21, 2017 at 12:21 PM, wrote: > We've found a bug in the syscall package (see > https://github.com/opencontainers/runc/issues/1364), and the better solution > seems to be to move from syscall to sys. I've started updating some of the > runc code to see how

[go-nuts] const type deduction

2017-03-21 Thread WinD zz
func main() { const abc = 111 fmt.Printf("%t\n", abc) fmt.Println(math.Pi * abc) fmt.Printf("%t", math.Pi) } result: %!t(int=111) 25.132741228718345 %!t(float64=3.141592653589793) func main() { const abc int = 111 fmt.Printf("%t\n", abc)

[go-nuts] Discussion on moving projects from syscall to sys/[platform]

2017-03-21 Thread christy
We've found a bug in the syscall package (see https://github.com/opencontainers/runc/issues/1364), and the better solution seems to be to move from syscall to sys. I've started updating some of the runc code to see how big of a change it would be, and have gotten a bit off in the weeds. I'd

[go-nuts] [ANN] atomic operations as methods on types

2017-03-21 Thread 'Ingo Oeser' via golang-nuts
Hi all, I wrote a small package which implements atomic operations on types. This is more comfortable to use and enabled building an atomic boolean type (which has been the motivation) here. Documentation at https://godoc.org/github.com/nightlyone/atomic Source code at:

[go-nuts] Golang http reverse proxy in production

2017-03-21 Thread James Pettyjohn
I'm looking at using the stock HTTP reverse proxy, briefly looking at the implementation it seems to be ready to withstand a production workload. Any cautions or caveats in going this route? - J -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Cancelling a server routine

2017-03-21 Thread Peter Bourgon
// establish the net.UDPConn and context.Context here. go func() { for { if err := conn.Read(p); err != nil { return } // do something with p } }() go func() { <-ctx.Done() conn.Close() // will interrupt the above goroutine with an error

Re: [go-nuts] atomic bugs

2017-03-21 Thread Ian Lance Taylor
On Tue, Mar 21, 2017 at 2:35 AM, T L wrote: > > On Tuesday, March 21, 2017 at 7:33:34 AM UTC+8, Ian Lance Taylor wrote: >> >> 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

Re: [go-nuts] Best practices for building libraries?

2017-03-21 Thread Peter Bourgon
On Tue, Mar 21, 2017 at 10:34 PM, wrote: > So I am new to Go and upon developing some things I am curious about best > practices for building/releasing libraries which will be used by other > programs in Go. > > Coming from a Java world, when you build a library, you

Re: [go-nuts] Expression evaluation with side effects

2017-03-21 Thread Ian Lance Taylor
On Tue, Mar 21, 2017 at 10:38 AM, Paul Jolly wrote: >> The problem was that I repeatedly mentally misread 'indexing' for 'index >> evaluation'. As the index is a constant in this case, it lead me to believe >> it cannot have any effect on the result. But it's the 'indexing',

[go-nuts] Best practices for building libraries?

2017-03-21 Thread alethenorio
So I am new to Go and upon developing some things I am curious about best practices for building/releasing libraries which will be used by other programs in Go. Coming from a Java world, when you build a library, you build an actual artifact, thus having a separate process for testing +

Re: [go-nuts] Add a method to initialize string

2017-03-21 Thread Ian Lance Taylor
On Tue, Mar 21, 2017 at 1:26 PM, tamal wrote: > > I keep finding myself writing the following method often when working with > GO code. I wonder if this can be added to `strings` pkg. > > func get(s, init string) string { > if s == "" { > return init > } > return s > } The

[go-nuts] Re: Add a method to initialize string

2017-03-21 Thread Alexander Menzhinsky
So why don'y you create your own stringutils package? On Tuesday, 21 March 2017 15:26:18 UTC-5, tamal wrote: > > Hi, > I keep finding myself writing the following method often when working with > GO code. I wonder if this can be added to `strings` pkg. > > func get(s, init string) string { > if

[go-nuts] Add a method to initialize string

2017-03-21 Thread tamal
Hi, I keep finding myself writing the following method often when working with GO code. I wonder if this can be added to `strings` pkg. func get(s, init string) string { if s == "" { return init } return s } Thanks. -- You received this message because you are subscribed to the Google Groups

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

2017-03-21 Thread peterGo
s/greptext.go (https://play.golang.org/p/XzW6IBueyy)/greptext.go ( https://play.golang.org/p/-C9bVEJ2QP))/ On Tuesday, March 21, 2017 at 2:40:29 PM UTC-4, peterGo wrote: > > Harry, > > To be meaningful, benchmarks must be reproducible. > > You use some file with 10 million lines and 2.4

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

2017-03-21 Thread peterGo
Harry, To be meaningful, benchmarks must be reproducible. You use some file with 10 million lines and 2.4 gigabytes. grepin.go (https://play.golang.org/p/YGRAJ6dEVn) is a program that generates known input data. Your programs had variations other than Bytes() and Text(). grepbytes.go

Re: [go-nuts] getfileattributesex the system cannot find the file specified

2017-03-21 Thread John McKown
On Tue, Mar 21, 2017 at 12:40 PM, Gesse Barros wrote: > > Hello people. Beginner in this language. Can you help me solve this error? > Happens when compiling my first project > > ​Does this sound like your problem?

[go-nuts] getfileattributesex the system cannot find the file specified

2017-03-21 Thread Gesse Barros
Hello people. Beginner in this language. Can you help me solve this error? Happens when compiling my first project -- 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

Re: [go-nuts] Expression evaluation with side effects

2017-03-21 Thread Paul Jolly
> > The problem was that I repeatedly mentally misread 'indexing' for 'index > evaluation'. As the index is a constant in this case, it lead me to believe > it cannot have any effect on the result. But it's the 'indexing', the > actual time when the value is loaded using the index, which is exempt

Re: [go-nuts] Expression evaluation with side effects

2017-03-21 Thread Jan Mercl
On Tue, Mar 21, 2017 at 6:11 PM John McKown wrote: > ​Logically yes, but due the implementation, along with "side effects" (undocumented?), it does. The "x[0]|=foo()" moves x[0] to a temporary area. It then invokes foo(). It then does the logical or from the

Re: [go-nuts] Expression evaluation with side effects

2017-03-21 Thread John McKown
On Sun, Mar 19, 2017 at 6:20 PM, Steven Hartland wrote: > Think the following section should explain the strange behaviour you're > seeing: > https://golang.org/ref/spec#Order_of_evaluation > > On 19/03/2017 22:59, Jan Mercl wrote: > > While trying to resolve a failing

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

2017-03-21 Thread Ian Lance Taylor
On Mon, Mar 20, 2017 at 11:53 PM, Basile Starynkevitch wrote: > > On Monday, March 20, 2017 at 8:36:04 AM UTC+1, Basile Starynkevitch wrote: >> >> Plugins and packages in Go >> >> The package concept is a core concept of Go since every source file >> belongs to some

[go-nuts] testing for timing races

2017-03-21 Thread 'Han-Wen Nienhuys' via golang-nuts
Hi there, The transport protocol of the SSH package supports key changes, but has a mandatory key change at the start. Handling this has been a source of hard to reproduce bugs, eg. https://go.googlesource.com/crypto/+/d68c3ecb62c850b645dc072a8d78006286bf81ca

Re: [go-nuts] Re: Tour of Go - translation

2017-03-21 Thread medvigodev
It seems the playground on both go-tour-de and go-tour-de1 is broken. I get "Error communicating with remote server. Program exited." when running the first example. All other tours work (except go-tour-uz, where I get the same error). On Wednesday, February 11, 2015 at 9:26:22 PM UTC+1,

[go-nuts] Cancelling a server routine

2017-03-21 Thread Florian Forster
Hi Go nuts, I have a (server) function that gets a context.Context and *listens* on a net.UDPConn. I would like this function to receive and handle network packets, but close the socket and return as soon as the context is cancelled. Ideally, I'd like to do something along these lines: for {

Re: [go-nuts] go get and private repositories (GH:E)

2017-03-21 Thread andrey mirtchovski
Git doesn't care if the / is there or not (g...@github.com:user/foo.git and g...@github.com:/user/foo.git behave identically) the go tool expects the slash to be there when it converts from scp-like paths to https: $ go get g...@github.com:user/foo.git package g...@github.com:user/foo.git:

Re: [go-nuts] go get and private repositories (GH:E)

2017-03-21 Thread Jan Mercl
On Tue, Mar 21, 2017 at 4:44 PM andrey mirtchovski wrote: > any suggestions? AFAICT, public as well as private Github repository URLs do _not_ have the slash after the colon in the URL, like in g...@github.com:user/foo.git. -- -j -- You received this message because

[go-nuts] go get and private repositories (GH:E)

2017-03-21 Thread andrey mirtchovski
i'm trying to clone a repo from github enterprise. i've followed the instructions i could find and set up the following gitconfig: [url "git@1.2.3.4:"] insteadOf = ssh://git@1.2.3.4/ however i can't get past the vanity import check, instead getting: unrecognized import path

Re: [go-nuts] syscall: dup2 blocks contrary to runtime's expectations for fuse file systems

2017-03-21 Thread kirr
Hello up there. I've found this thread via https://github.com/golang/go/issues/19563#issuecomment-287920797 so let me chime in and comment a bit: 1. The problem of sys_dup2 blocking is not FUSE-only. By definition dup2 may end up closing newfd: If the file descriptor newfd was previously

[go-nuts] Debugging large Go binaries

2017-03-21 Thread Nyah Check
Hi Gophers, I've been working on this document for some months now for Docker. It basically requires writing a document to debug large docker binary files. I've done some research on this; I just need some pointers

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

2017-03-21 Thread David Collier-Brown
Hidden isn't used by Go at this time, but if it's part of the elf tradition, then the term probably refers to the same thing that Sunw_PRIVATE did on Solaris: this symbol can only be used within the library, not by anyone outside it. It's a tiny bit of a kludge: we didn't realize we needed a

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

2017-03-21 Thread Paulius Daubaris
Oh, that's nice, didnt think the solution is that easy, thank you, that was what I was looking for! 2017 m. kovas 21 d., antradienis 09:45:13 UTC+2, Pierre Curto rašė: > > Hello, > > You keep appending json objects to your file, which produces invalid json > after the first item. > You either

Re: [go-nuts] atomic bugs

2017-03-21 Thread T L
On Tuesday, March 21, 2017 at 7:33:34 AM UTC+8, Ian Lance Taylor wrote: > > 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 > >

[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-21 Thread T L
On Tuesday, March 21, 2017 at 1:29:39 AM UTC+8, peterGo wrote: > > T L, > > For example: https://play.golang.org/p/BSwB8jQwBY > Peter > Yes, there are some bytes padded, but for the struct S. The size of the struct S is 16 bytes, so there is no paddings when it is used as element of an array.

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

2017-03-21 Thread Konstantin Khomoutov
On Tue, 21 Mar 2017 11:23:39 +0300 Konstantin Khomoutov wrote: [...] Sorry, a couple of assorted fixes: > A sketch would look something like this: > > /* > typedef MediaHandle uint64_t Should be typedef uint64_t MediaHandle of course. > */ >

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

2017-03-21 Thread Konstantin Khomoutov
On Mon, 20 Mar 2017 23:21:20 -0700 (PDT) Song Liu wrote: > Default symbol could break loading multiple shared lib implemented by > different version of go runtime, if there is one symbol with same > name but with different logic. This actually means they won't be compatible

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

2017-03-21 Thread Konstantin Khomoutov
On Mon, 20 Mar 2017 06:25:01 -0700 (PDT) Song Liu wrote: [...] > struct Media { > > char*Name; > > char*Path; > > uint64_t Size; > > }; [...] > func GetMediaFromDB(filename *C.char) *C.struct_Media { > > > c_struct_media := _Media{} > > >

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

2017-03-21 Thread pierre . curto
Hello, You keep appending json objects to your file, which produces invalid json after the first item. You either need to produce valid json, for instance by putting your items into an array, or use a streaming json parser that parses items individually. I have changed your example to perform

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

2017-03-21 Thread Tyler Compton
Thanks for the help! This is what I'm looking for. On Mon, Mar 20, 2017 at 6:32 PM Marian Kopriva wrote: > 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 >

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

2017-03-21 Thread Basile Starynkevitch
On Monday, March 20, 2017 at 8:36:04 AM UTC+1, Basile Starynkevitch wrote: > *Plugins and packages in Go* > > The *package* concept is a core concept of Go since every source file belongs > to some package (with main being a special case) and often imports several > other ones. > Practically

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

2017-03-21 Thread Konstantin Khomoutov
On Tue, 21 Mar 2017 04:48:50 + Harley Laue wrote: > 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 }

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

2017-03-21 Thread Song Liu
Thanks for your info, it seems that it's reporting the same error but still not have a solution. After tried to use unsafe: return (*C.struct_Media)(unsafe.Pointer(c_struct_media)) it reports same error: panic: runtime error: cgo result has Go pointer Any further insights about this issue?

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

2017-03-21 Thread Song Liu
Default symbol could break loading multiple shared lib implemented by different version of go runtime, if there is one symbol with same name but with different logic. And, the shared lib implemented by Go has too many symbols from the Go runtine and libraries, which will result in the loading