Re: [go-nuts] is this code thread safety?

2017-11-02 Thread Jesse McNelis
On Thu, Nov 2, 2017 at 4:54 PM, sheepbao wrote: > > the close function is thread safety? how about call `closed` at the same > time. It's not safe. Multiple goroutines can enter the 'default' case in that select and close() the channel multiple times. "Sending to or

[go-nuts] Re: Announcing: Skylark in Go

2017-11-02 Thread Ben Hoyt
That looks really neat. I will dive into the code! I'm very curious how the performance of Skylark in Go compares to Skylark in Java (and CPython 3.6 for that matter) -- any benchmarks on that? -Ben On Monday, October 2, 2017 at 12:39:43 PM UTC-4, Alan Donovan wrote: > > I'm pleased to

[go-nuts] Re: Handling dynamic and unknown number of wait groups?

2017-11-02 Thread David Collier-Brown
You don't even need to do waitgroups if the main() function is the one that is last in the pipeline: cf https://leaflessca.wordpress.com/2017/01/04/forwards-and-backwords-pipes-in-go/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: Handling dynamic and unknown number of wait groups?

2017-11-02 Thread David Collier-Brown
You don't even mneed to do weaitgroups if the main() function is the one that is last in the pipeline : cf https://leaflessca.wordpress.com/2017/01/04/forwards-and-backwords-pipes-in-go/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: Possible dep issue: package revision in Gopkg.lock doesn't match constraint in Gopkg.toml

2017-11-02 Thread Justin Lovero
Thanks, Dave! Using [[override]] fixed the problem [[override]] name = "github.com/ugorji/go" revision = "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74" That's all I needed. *dep* seems to have problems resolving the correct transitive dependency versions at the moment. Hope they get that fixed

Re: [go-nuts] Bizarre Error Message (Go 1.9.2)

2017-11-02 Thread Raffaele Sena
Or you use the "standard" unix trick: go run ls.go -- ls.go On Thu, Nov 2, 2017 at 1:55 PM, Ian Lance Taylor wrote: > On Thu, Nov 2, 2017 at 10:37 AM, Jon Forrest wrote: > > > > I'm learning Go. Whenever I learn a new programming language I like to > try >

Re: [go-nuts] Bizarre Error Message (Go 1.9.2)

2017-11-02 Thread Ian Lance Taylor
On Thu, Nov 2, 2017 at 10:37 AM, Jon Forrest wrote: > > I'm learning Go. Whenever I learn a new programming language I like to try > to recreate the Unix 'ls' command > in that language. I've found that such an exercise is often a good way to > get familiar with what a language

Re: [go-nuts] Get Time in the past

2017-11-02 Thread Shawn Milochik
Just use Add and a negative duration: https://play.golang.org/p/ueYLh1nrps -- 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

[go-nuts] Re: concurrency programing about go

2017-11-02 Thread snmed
Hi Here is the code: Version 1: package main import ( "fmt" "sync" ) var a string var once sync.Once func setup() { a = "hello,world\n" } func doprint() { once.Do(setup) fmt.Print(a) } func twoprint() <-chan struct{} { var wg sync.WaitGroup wg.Add(2) ch := make(chan struct{}) go func() {

[go-nuts] Get Time in the past

2017-11-02 Thread jonatas . baldin
Hi there, how are you doing? I'd like to get a time.Time 1h hour in the past. I see in the documentation that Go has a time.Add functions, it would be something like this, but for subtraction. The time.Sub function returns a Duration type, and I need a Time type. Thanks! -- You received this

[go-nuts] Re: Is there a best way to use a global httpclient but with a different timeout setting per request?

2017-11-02 Thread K Wang
ctx, cancel = context.WithTimeout(context.Background(), client.Timeout) On Tuesday, October 31, 2017 at 5:52:29 AM UTC-7, 慕希颜 wrote: > > Is there a way to add a timeout setting for per request if i declare a > global var? Because in my case i need different timeout setting for per >

[go-nuts] Re: Announcing: Skylark in Go

2017-11-02 Thread Zellyn
This looks neat. Are you able to provide more context on what this is/will be used for at Google? On Monday, October 2, 2017 at 12:39:43 PM UTC-4, Alan Donovan wrote: > > I'm pleased to announce the launch of Skylark in Go: an interpreter for > Skylark, implemented in Go. > >

[go-nuts] [ANN] GoLand EAP 18 (Go IDE from JetBrains) now supports Go templates

2017-11-02 Thread Florin Pățan
The latest release brings a big update for the IDE: - final name changed from the (initial) codename to GoLand - Go templates are now supported with more improvements to be done in the future - pricing information and general availability target date are also announced Please give it a try and

Re: [go-nuts] network programming about go

2017-11-02 Thread Justin Israel
On Mon, Oct 30, 2017, 7:55 PM <2891132l...@gmail.com> wrote: > I write this code in the follwings: > package main > > import ( > "fmt" > "net" > "os" > ) > > func main() { > service := ":5000" > tcpAddr, err := net.ResolveTCPAddr("tcp", service) > checkError(err) > listener, err :=

[go-nuts] Re: Handling dynamic and unknown number of wait groups?

2017-11-02 Thread howardcshaw
You absolutely can use goroutines without waitgroups! It all depends on what you are doing with them. Where waitgroups come in is when you need to something only after *all* of the goroutines on a specific task are done. Chances are that if you are not using waitgroups, you are either using

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2017-11-02 Thread Henrik Johansson
And technically they are not tracking goroutines but done things. Each goroutine could each finish 10 things. On Thu, 2 Nov 2017, 17:01 Andy Balholm, wrote: > You can add goroutines to a WaitGroup as you create them. There is nothing > that keeps you from calling Add more

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2017-11-02 Thread Andy Balholm
You can add goroutines to a WaitGroup as you create them. There is nothing that keeps you from calling Add more than once. Andy > On Nov 1, 2017, at 11:10 PM, kanth...@gmail.com wrote: > > I am new to Go and I had read numerous times in various articles that one can > technically create any

[go-nuts] Re: Handling dynamic and unknown number of wait groups?

2017-11-02 Thread kanth909
I am new to Go and I had read numerous times in various articles that one can technically create any number of Go routines and the runtime takes care of them mapping to kernel threads. If so, why does waitGroup designed in a way such that one has to specify how many go routines one need to

[go-nuts] liteide x33 released!

2017-11-02 Thread visualfc
Hi, all. liteide x33 released! This version optimizes the editor function, reads the file support codec automatically detects, reloads the file using diff way to optimize, re-implements the Mark API and adds new Bookmarks plugin. Go classview and outline adds TodoList display. Fixes GolangEdit

[go-nuts] Re: concurrency programing about go

2017-11-02 Thread 2891132love
Sorry,I try my best to open the website but it can't work.Can you write it ??Thank you so much. 在 2017年10月30日星期一 UTC+8下午4:29:44,snmed写道: > > Hi > > There are several ways to solve it, here are two of them: > > https://play.golang.org/p/wJwkI7HQwv > https://play.golang.org/p/nasUcgBeG4 > > I

Re: [go-nuts] Re: Appengine and main package

2017-11-02 Thread Sankar P
Thanks. 2017-11-02 10:06 GMT+05:30 Chris Broadfoot : > You can use a main package. > > package main > > import ( >"net/http" >"google.golang.org/appengine" > ) > > func main() { >http.HandleFunc(...) >appengine.Main() > } > > > On Wednesday, November

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-02 Thread Volker Dobler
On Wednesday, 1 November 2017 12:19:19 UTC+1, JuciÊ Andrade wrote: > > Ayan, imagine I am part of a development team. In our program I have a > pointer r: > > r *myType > > My variable r can be nil, because that is a valid situation. It is used in > dozens of places, like this: > > if r != nil {