Re: [go-nuts] Inconsistent reporting of unused package variable initialized in init() but used elsewhere

2019-02-23 Thread Kurtis Rader
Global vars are inherently problematic. As mirtchov...@gmail.com noted you are shadowing the global var in your first example. Which is why the global var isn't updated. I'm only responding because as a grey beard I am dismayed that today I see so many instances of global vars that should have more

Re: [go-nuts] Inconsistent reporting of unused package variable initialized in init() but used elsewhere

2019-02-23 Thread andrey mirtchovski
in https://play.golang.org/p/5P5vcebYkGj you're shadowing s by creating a new variable via := this is a common go interview question :) On Sat, Feb 23, 2019 at 9:34 PM wrote: > > Hello, > > It's likely that I'm misinterpreting the language spec. It's also easy to > circumvent by assigning the o

[go-nuts] Inconsistent reporting of unused package variable initialized in init() but used elsewhere

2019-02-23 Thread gnirodi
Hello, It's likely that I'm misinterpreting the language spec. It's also easy to circumvent by assigning the offending variable to _. Even if this turns out to be complying with the spec, thought this post may help anyone else looking up this forum for answers. https://play.golang.org/p/5P5

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-23 Thread Ian Denhardt
Quoting David Finkel (2019-02-23 16:09:18) >Not only is fmt.Printf a function call, but it makes a blocking >syscall >(write specifically), >which gives the go runtime license to spin up a new OS thread and >immediately schedule the other goroutine. >runtime.GOMAXPROCS(1) o

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-23 Thread David Finkel
[The other responses have been excellent, but I wanted to point one thing out.] On Fri, Feb 22, 2019 at 3:17 AM Jingguo Yao wrote: > Consider the following code which launches two goroutines. Each > goroutine uses a for loop to print messages. > > package main > > import ( > "fmt" > "run

Re: [go-nuts] Visual Studio Code oddity with Go

2019-02-23 Thread Joseph
Rich, you should check where your GOPATH is pointing. My guess is that VSCode is successfully installing the tool, but it's installing it in the "wrong" place. I have my $GOPATH is set to "\go" and my project folder structure is "$GOPATH\src\myDomain.com\myProject\main.go" and when I run VSCode

[go-nuts] Unmarshal nested XML value from dynamic XML document

2019-02-23 Thread Tamás Gulácsi
Walk over it usin xml.Decoder.Token, and UnmarshalElement when found a StartToken with a proper Name.Local. -- 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 golan

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-23 Thread Jingguo Yao
Ian: Thanks for your explanation. On Saturday, February 23, 2019 at 1:13:04 AM UTC+8, Ian Denhardt wrote: > > In the new example, goroutine 2 should get pre-empted at time.Sleep. > goroutine 1 may hog a CPU however. There's an open issue about this, > which is being worked on. > > https://

[go-nuts] Unmarshal nested XML value from dynamic XML document

2019-02-23 Thread Steffen Wentzel
Hi all, although I'm sure this question came up already I wasn't able to find a solution for my issue. I have this example XML structure: {D4564-4564-456-4564456} I want to unmarshal the ID value contained in the XML tags. However this XML structure is dynamic, the embedding XML tag

Re: [go-nuts] Good metaphor for differentiating Go from other languages?

2019-02-23 Thread Chris Burkert
For me Go is the small but complete toolbox you need to build anything. Tim Allens Home Improvement and Binford comes to my mind :-) Randall O'Reilly schrieb am Sa. 23. Feb. 2019 um 05:40: > On the topic of “selling” the advantages of Go vs. other languages such as > Python and C++, has anyone u