[go-nuts] Re: sync.Map for caching

2017-08-31 Thread bep
Thanks, snmed, I was looking at LoadOrStore, but I was assuming that any func would be executed in any case. A more illustrative running sample of your first example: https://play.golang.org/p/vjlVu1GnUQ Thanks again! bep fredag 1. september 2017 08.24.10 UTC+2 skrev snmed følgende: > > Hi

[go-nuts] Re: sync.Map for caching

2017-08-31 Thread snmed
Hi Here are two examples how to achieve it: https://play.golang.org/p/wAtyGMSw6g or https://play.golang.org/p/EZWZUOpuwb First example: In best cases it executes the creator function once and returns always the stored item, in bad cases it executes the creator function multiple times but retu

Re: [go-nuts] sync.Map for caching

2017-08-31 Thread Henrik Johansson
If you absolutely must make sure you ever create 2 instances of any value in the map then I guess you have to lock. Otherwise you can maybe use map.LoadOrStore? fre 1 sep. 2017 kl 00:18 skrev bep : > sync.Map in Go 1.9 is a little low on examples/doc in the wild, so I > thought I should ask here.

[go-nuts] Go1.9 different behavior of pem.Decode() for copied binary slice

2017-08-31 Thread aloukian
After I upgraded my Go from 1.8.1 I noticed several test failures. I zeroed down on the root cause for these failures and it appears that now pem.Decode behaves differently In tests that fail PEM encoded certificate is copied to another preallocated byte array using copy function and then pem.D

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread burpswangy
Thanks. I actually moved it to /etc/environment... reboot... and it picked it up. Appreciate the help, guys. On Thursday, August 31, 2017 at 8:50:22 PM UTC-5, James Bardin wrote: > > > > On Thursday, August 31, 2017 at 9:46:11 PM UTC-4, burpswangy wrote: >> >> Wow, actually... that did work. I

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread James Bardin
On Thursday, August 31, 2017 at 9:46:11 PM UTC-4, burpswangy wrote: > > Wow, actually... that did work. I was using 'set GOPATH' and not 'export > GOPATH'. I have GOPATH defined in my /etc/bash.bashrc... is there anywhere > else I should be putting it? > >> >>> You should be using a profile f

[go-nuts] Re: Why isn't golang input and output is buffered?

2017-08-31 Thread as
Once something is buffered, it can not be unbuffered. That is, the latency of the I/O operations permanently increase with respect to the properties of the buffering done underneath. Go does not buffer things by default because not everyone wants to buffer things by default. This is also why Na

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread burpswangy
Wow, actually... that did work. I was using 'set GOPATH' and not 'export GOPATH'. I have GOPATH defined in my /etc/bash.bashrc... is there anywhere else I should be putting it? On Thursday, August 31, 2017 at 8:44:33 PM UTC-5, burpswangy wrote: > > I did... to no avail. I'm so confused right

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread burpswangy
I did... to no avail. I'm so confused right now, lol. I even su root and tried doing things under there, just in case it was something user-specific causing it. Nothing I do changes it. On Thursday, August 31, 2017 at 8:40:07 PM UTC-5, Ayan George wrote: > > > > On 08/31/2017 09:38 PM, burpsw

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread Nilsocket .
Optimizations were really great. Can somebody tell me, why isn't buffered i/o isn't used by default. >It's true that fmt.Scanf works on the unbuffered os.Stdin. That is the correct choice when os.Stdin is used for different things. Ian Lance Taylor, have mentioned it, but it is too short for

Re: [go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread Ayan George
On 08/31/2017 09:38 PM, burpswangy wrote: > Debian 9.1 Stretch... using Go 1.9, go env shows GOPATH=/home/dev/go > while echo $GOPATH=/home/dev/devSync/workspace. > > No matter what I do, I can't get Go 1.9 to find my workspace! What is > goin' on!? > have you tried: export GOPATH=/home/dev/

[go-nuts] go env GOPATH not reflecting $GOPATH

2017-08-31 Thread burpswangy
Debian 9.1 Stretch... using Go 1.9, go env shows GOPATH=/home/dev/go while echo $GOPATH=/home/dev/devSync/workspace. No matter what I do, I can't get Go 1.9 to find my workspace! What is goin' on!? -- You received this message because you are subscribed to the Google Groups "golang-nuts" gro

Re: [go-nuts] Assigning files (names) to string array.

2017-08-31 Thread Ayan George
On 08/31/2017 08:41 PM, djl...@gmail.com wrote: > I am pretty new it GoLang but I am trying to read file directorys and > assign the directory name to array list. > > Exampe I have been working with this > > funccaptureDir() { >files, err:=ioutil.ReadDir("./") >iferr !=nil{ >log

[go-nuts] Assigning files (names) to string array.

2017-08-31 Thread djlw78
I am pretty new it GoLang but I am trying to read file directorys and assign the directory name to array list. Exampe I have been working with this func captureDir() { files, err := ioutil.ReadDir("./") if err != nil { log.Fatal(err) } for _, f := range files { dirlis

Re: [go-nuts] go1.9: problem with go get

2017-08-31 Thread Ian Lance Taylor
On Thu, Aug 31, 2017 at 12:51 PM, abriese wrote: > ~/Download/ $ go build github.com/AndreasBriese/breeze > # runtime > /usr/local/go/src/runtime/mstkbar.go:151:10: debug.gcstackbarrieroff > undefined (type struct { allocfreetrace int32; cgocheck int32; efence int32; > gccheckmark int32; gcpacertr

Re: [go-nuts] Why do interfaces sometimes require pointers to be satisfied?

2017-08-31 Thread Ian Lance Taylor
On Thu, Aug 31, 2017 at 2:05 PM, wrote: > > On Thursday, August 31, 2017 at 12:45:25 PM UTC-7, Ian Lance Taylor wrote: >> >> On Thu, Aug 31, 2017 at 11:50 AM, wrote: >> >> > 1. method/function parameters are not coerced by the compiler. If a >> > parameter calls for a pointer, it must be a poin

[go-nuts] Position at Red Hat for a Go engineer

2017-08-31 Thread Jeff Law
Red Hat is currently looking to hire an engineer in the Golang space. Information on the position and application link can be found here: https://careers-redhat.icims.com/jobs/59029/senior-software-engineer---golang/job If after reviewing that page you have questions, you can certainly contact

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Jason E. Aten
On Thursday, August 31, 2017 at 3:23:02 PM UTC-5, Ian Lance Taylor wrote: > > On Thu, Aug 31, 2017 at 7:45 AM, Jason E. Aten > wrote: > > On Thursday, August 31, 2017 at 9:23:58 AM UTC-5, Konstantin Khomoutov > > wrote: > >> > >> Still, I don't see any specific wording regarding this in the

[go-nuts] sync.Map for caching

2017-08-31 Thread bep
sync.Map in Go 1.9 is a little low on examples/doc in the wild, so I thought I should ask here. The new type is promoted as a replacement for RWMutex in mostly read use cases with stable keys. I assume that a typical in memory cache would fit that description. With RWMutex, if the cost of cre

Re: [go-nuts] Why do interfaces sometimes require pointers to be satisfied?

2017-08-31 Thread macrae . linton
On Thursday, August 31, 2017 at 12:45:25 PM UTC-7, Ian Lance Taylor wrote: > > On Thu, Aug 31, 2017 at 11:50 AM, > > wrote: > > > 1. method/function parameters are not coerced by the compiler. If a > > parameter calls for a pointer, it must be a pointer at the call site. > > 2. method receiv

[go-nuts] Re: go1.9: problem with go get

2017-08-31 Thread mhhcbon
can this thread helps ? https://groups.google.com/forum/#!topic/golang-nuts/wAYxijyyL5U On Thursday, August 31, 2017 at 10:23:07 PM UTC+2, abriese wrote: > > ~/Download/ $ go build github.com/AndreasBriese/breeze > # runtime > /usr/local/go/src/runtime/mstkbar.go:151:10: debug.gcstackbarrieroff

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Ian Lance Taylor
On Thu, Aug 31, 2017 at 7:45 AM, Jason E. Aten wrote: > On Thursday, August 31, 2017 at 9:23:58 AM UTC-5, Konstantin Khomoutov > wrote: >> >> Still, I don't see any specific wording regarding this in the spec -- >> neither in its section on channels nor in its section on the close() >> function. >

[go-nuts] go1.9: problem with go get

2017-08-31 Thread abriese
~/Download/ $ go build github.com/AndreasBriese/breeze # runtime /usr/local/go/src/runtime/mstkbar.go:151:10: debug.gcstackbarrieroff undefined (type struct { allocfreetrace int32; cgocheck int32; efence int32; gccheckmark int32; gcpacertrace int32; gcshrinkstackoff int32; gcrescanstacks int32;

[go-nuts] Re: Golang 1.9 failing with excelize (simple case works under 1.8.3)

2017-08-31 Thread G Shields
All, Thanks for all the suggestions. I cleaned out everything with: go clean -r -i … installed go 1.9 and created a file new test file of: package main import ( "fmt" "os" "github.com/plandem/xlsx" ) func checkErr(err error) { if err != nil { fmt.Println(err) os.

[go-nuts] Why do interfaces sometimes require pointers to be satisfied?

2017-08-31 Thread Tamás Gulácsi
As a short rule: if sth needs to be modified, a pointer is needed. If only some result of computation, a value is enough. -- 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 e

Re: [go-nuts] Why do interfaces sometimes require pointers to be satisfied?

2017-08-31 Thread Ian Lance Taylor
On Thu, Aug 31, 2017 at 11:50 AM, wrote: > > I was bitten this week by not understanding how interfaces in method > parameters interacted with pointers. After playing around I finally figured > out these rules > > 1. method/function parameters are not coerced by the compiler. If a > parameter cal

[go-nuts] Why do interfaces sometimes require pointers to be satisfied?

2017-08-31 Thread macrae . linton
I was bitten this week by not understanding how interfaces in method parameters interacted with pointers. After playing around I finally figured out these rules 1. method/function parameters are not coerced by the compiler. If a parameter calls for a pointer, it must be a pointer at the call si

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread Michael Jones
By the way, if we're willing to do it all...we can take it down a little more: https://play.golang.org/p/DNxQT01vy9 read 100 26.174853ms sort 100 180.17782ms On Thu, Aug 31, 2017 at 11:28 AM, Michael Jones wrote: > Nice! Is "bytconv" shared somewhere? > > On Thu, Aug 31, 2017 at 10:53 A

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread Michael Jones
Nice! Is "bytconv" shared somewhere? On Thu, Aug 31, 2017 at 10:53 AM, peterGo wrote: > Michael, > > n your code, you have : > > const n = 1000 * 1000 > > for i := 0; i < n && scan.Scan(); i++ { > d, _ := strconv.Atoi(scan.Text()) > array[i] = int64(d) > } > > https://play.golang.org/p/S

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread peterGo
Michael, n your code, you have : const n = 1000 * 1000 for i := 0; i < n && scan.Scan(); i++ { d, _ := strconv.Atoi(scan.Text()) array[i] = int64(d) } https://play.golang.org/p/SgpAXyvsGs Here's a benchmark that demonstrates the fundamental issue, unnecessary string conversions. , Ben

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread peterGo
Michael, Your read times look slow to me. I used bytconv instead of strconv. bytconv: read 100 98.517584ms sort 100 481.994354ms strconv: read 100 174.720883ms sort 100 479.437831ms bytconv is the missing Go standard library package. bytconv is the byte input analog of string i

Re: [go-nuts] Running Go binary on a 56 core VM

2017-08-31 Thread Henrik Johansson
Try it out! It would be great if the scheduler and garbage collector could be so good as to making such tricks unnecessary. On Thu, 31 Aug 2017, 15:59 wrote: > Hi Guys, > > So, we wrote a Go service which does some heavy network IO over ZMQ (using > cgo calls). > > Now, we have to put this servi

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Jason E. Aten
On Thursday, August 31, 2017 at 9:23:58 AM UTC-5, Konstantin Khomoutov wrote: > > Still, I don't see any specific wording regarding this in the spec -- > neither in its section on channels nor in its section on the close() > function. > Looks like it. So relying on this behavior could result i

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Konstantin Khomoutov
[...] > > AFAIK, all operations on a channel happen in-order and are fully > > serialized. That is, close() will wait until the currently active > > operation > > is active, if any. > > > > In other words, close() on a channel is not like closing an OS file > > descriptor -- even though the o

[go-nuts] Running Go binary on a 56 core VM

2017-08-31 Thread rautelap
Hi Guys, So, we wrote a Go service which does some heavy network IO over ZMQ (using cgo calls). Now, we have to put this service on a VM in private cloud which has 56 cores and 256GB of physical memory. I am guessing it is mostly a dual core NUMA Intel Xeon machine with Xen installed on it.

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Jason E. Aten
On Thursday, August 31, 2017 at 7:40:23 AM UTC-5, Konstantin Khomoutov wrote: > > On Thu, Aug 31, 2017 at 05:08:23AM -0700, Jason E. Aten wrote: > > > A question for those familiar with the runtime internals of channel > close > > and channel receive: > [...] > > Will closing a channel in t

Re: [go-nuts] english language help

2017-08-31 Thread 'Niko Schwarz' via golang-nuts
I think it's ok to ask in Russian on this group, too. On Wednesday, August 30, 2017 at 4:34:19 PM UTC+2, Oleg Puchinin wrote: > > ОНО > Спасибо ! > > 2017-08-30 20:30 GMT+06:00 Konstantin Khomoutov >: > >> On Wed, Aug 30, 2017 at 07:17:26PM +0600, Oleg Puchinin wrote: >> >> > Hello ! >> > Anybody

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Konstantin Khomoutov
On Thu, Aug 31, 2017 at 05:08:23AM -0700, Jason E. Aten wrote: > A question for those familiar with the runtime internals of channel close > and channel receive: [...] > Will closing a channel in the middle of a send introduce the possibility of > data corruption? The language spec guarantees a

[go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Jason E. Aten
A question for those familiar with the runtime internals of channel close and channel receive: In trying to get channels to match the superior performance of sync.Cond, I have come across one potentially viable strategy: using close to interrupt an otherwise blocked send. For example: ch := ma

[go-nuts] termbox trouble w/ go 1.9

2017-08-31 Thread rob
I fixed my previous error w/ Ian's help. Now I'm getting this error when I type go get github.com/nsf/termbox-go package github.com/nsf/termbox-go: directory "/home/rob/gocode/src/github.com/nsf/termbox-go" is not using a known version control system I have initialized git on this computer

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-31 Thread Peter Waller
I think this question is a protocol problem more than anything. A quick bit of searching "http server abort upload" reveals what to do: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14 https://groups.google.com/forum/#!topic/golang-nuts/agB-n6V7UsQ There is also this informativ

Re: [go-nuts] Building gopath packages

2017-08-31 Thread Konstantin Khomoutov
> > See github.com/rjeczalik/gobin for updating, but a simple > > "go install $GOPATH/src/..." may be enough. > > The URL appears to 404. There are multiple projects called "gobin" on > Github but neither appear to be concerned with the task we're > discussing, unfortunately. Citing the answer T

Re: [go-nuts] Re: expected bahaviour for fmt.Stringer within a container in a struct?

2017-08-31 Thread Dan Kortschak
Well that's dumb of me - too busy thinking about other details and forgetting the language I was speaking. Thanks. On Thu, 2017-08-31 at 01:24 -0700, moehrmann via golang-nuts wrote: > m is an unexported Field. fmt can not use interface() on the reflect > values  > to then call String on them on a

[go-nuts] Re: expected bahaviour for fmt.Stringer within a container in a struct?

2017-08-31 Thread moehrmann via golang-nuts
m is an unexported Field. fmt can not use interface() on the reflect values to then call String on them on anything unexported or below. This also happens if m is just interface{} and not a map: https://play.golang.org/p/ODrjW3Fslf If m is made an exported field by naming it M it works: https:/

Re: [go-nuts] Unmarshal multiple similar XML Files

2017-08-31 Thread Jeffrey Smith
Thanks a lot for that, simplifies my code massively :-) -- 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

Re: [go-nuts] Building gopath packages

2017-08-31 Thread Konstantin Khomoutov
On Wed, Aug 30, 2017 at 10:35:46PM -0700, Tamás Gulácsi wrote: > See github.com/rjeczalik/gobin for updating, but a simple > "go install $GOPATH/src/..." may be enough. The URL appears to 404. There are multiple projects called "gobin" on Github but neither appear to be concerned with the task w

Re: [go-nuts] Unmarshal multiple similar XML Files

2017-08-31 Thread Jakob Borg
On 31 Aug 2017, at 09:30, Jeffrey Smith wrote: > > I'm trying to Unmarshal multiple XML files that have differing top level > elements but the rest of the document is identical. You can use the XMLName attribute for this: https://play.golang.org/p/4nIrfbaC37 //jb -- You received this messag

[go-nuts] Unmarshal multiple similar XML Files

2017-08-31 Thread Jeffrey Smith
I'm trying to Unmarshal multiple XML files that have differing top level elements but the rest of the document is identical. ... ... I have tried adding multiple tags in the struct but it only ever uses the first one. type EspFlowCodeOperation struct { XMLName xml.Name `xml