[go-nuts] Migrating to modules

2019-06-26 Thread lee
All of my projects at the moment are living under GOPATH/src/me/projectName. Is it possible to migrate to using GoModules and pin (for now) the packages at the versions stored in my GOPATH/src. I am thinking that way the migration to GOMODULES will produce a build no different to the build

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Kurtis Rader
On Wed, Jun 26, 2019 at 8:30 PM Chou Yan wrote: > // NewRandW creates a new RandW with a random object. > func NewRandW() *RandW { > return {r: rand.New(rand.NewSource(time.Now().Unix()))} > } > That is broken even if you use `UnixNano()`. Repeat after me: In general you should never initialize

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Chou Yan
It's the context: // NewRandW creates a new RandW with a random object. func NewRandW() *RandW { return {r: rand.New(rand.NewSource(time.Now().Unix()))} } n := w.Next() // Next returns next selected item. func (rw *RandW) Next() (item interface{}) { ... randomWeight :=

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Kurtis Rader
On Wed, Jun 26, 2019 at 8:18 PM Chou Yan wrote: > I fix it by : > > var w = weighted.NewRandW() > Insufficient context to understand what that does. Let alone how it "fixes" the problem since you haven't shown us your `NewRandW()` function. In general you should never initialize a RNG more than

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Chou Yan
thx. you are right. I make a mistake. I negleck that my func will be called by mass goroutine, it will get the same seed and the same sequence 在 2019年6月27日星期四 UTC+8上午11:07:28,Kurtis Rader写道: > > Works for me: https://play.golang.org/p/zD5F7gp41re > > Like Burak I suspect you are initializing the

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Chou Yan
I fix it by : var w = weighted.NewRandW() func WeightRandom(services []*registry.Service) Next{ for _, service := range services { for _,n := range service.Nodes { w.Add(n,n.Weight) } } return func() (*registry.Node, error) { n := w.Next() no, ok := n.(*registry.Node) if !ok { return

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Chou Yan
The situation I am currently experiencing is that it only occur on my online app. I try it at local but I can not got the result. haha... I make a mistake. the code is : func WeightRandom(services []*registry.Service) Next{ w := weighted.NewRandW() for _, service := range services { for _,n :=

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Kurtis Rader
Works for me: https://play.golang.org/p/zD5F7gp41re Like Burak I suspect you are initializing the RNG in a tight loop. Since `time.Now().Unix()` has a resolution of one second you end up generating the same initial value every time through the loop until the current time advances to the next

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Burak Serdar
On Wed, Jun 26, 2019 at 8:48 PM Chou Yan wrote: > > like this: > r:=rand.New(rand.NewSource(time.Now().Unix())) > for { > r.Intn(96) > } > I know the same seed will generate the same sequence. But I don't know why it > generate mass same number when I use seed of 'time.Now().Unix()', But

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Chou Yan
like this: r:=rand.New(rand.NewSource(time.Now().Unix())) for { r.Intn(96) } I know the same seed will generate the same sequence. But I don't know why it generate mass same number when I use seed of 'time.Now().Unix()', But when I use seed of 'time.Now().UnixNano()', It will not. I

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Burak Serdar
On Wed, Jun 26, 2019 at 8:17 PM Chou Yan wrote: > > I use: > r:=rand.New(rand.NewSource(time.Now().Unix())) > r..Intn(96) How are you generating multiple random numbers? If your loop that generates these numbers include the r:=rand.New(...), then you're essentially seeding the random number

Re: [go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now

2019-06-26 Thread Kurtis Rader
On Wed, Jun 26, 2019 at 7:17 PM Chou Yan wrote: > I use: > r:=rand.New(rand.NewSource(time.Now().Unix())) > r..Intn(96) > That isn't valid Go. Which `rand` package? The one in package `crypto` or `math`? What the heck is `r..Intn(96)`? Please post a minimal, complete, example that compiles and

[go-nuts] rand seed using 'time.Now().Unix()' consequence mass common rand numbers, but using unixNano as the seed will not ,how to choose the rand's seed between 'time.Now().Unix()' and 'time.Now().U

2019-06-26 Thread Chou Yan
I use: r:=rand.New(rand.NewSource(time.Now().Unix())) r..Intn(96) I got: and val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand val: 82 rand

Re: [go-nuts] go build src code of `go doc`

2019-06-26 Thread Ian Lance Taylor
On Wed, Jun 26, 2019 at 4:54 PM Gert wrote: > > On Thursday, June 27, 2019 at 1:44:20 AM UTC+2, Gert wrote: >> >> On Thursday, June 27, 2019 at 12:11:58 AM UTC+2, Ian Lance Taylor wrote: >>> >>> On Wed, Jun 26, 2019 at 1:39 PM Gert wrote: >>> > >>> > Hmm trying to work on the src code of `go

Re: [go-nuts] go build src code of `go doc`

2019-06-26 Thread Gert
On Thursday, June 27, 2019 at 1:44:20 AM UTC+2, Gert wrote: > > On Thursday, June 27, 2019 at 12:11:58 AM UTC+2, Ian Lance Taylor wrote: >> >> On Wed, Jun 26, 2019 at 1:39 PM Gert wrote: >> > >> > Hmm trying to work on the src code of `go doc` but every time I try to >> compile a ./doc binary

Re: [go-nuts] go build src code of `go doc`

2019-06-26 Thread Gert
On Thursday, June 27, 2019 at 12:11:58 AM UTC+2, Ian Lance Taylor wrote: > > On Wed, Jun 26, 2019 at 1:39 PM Gert > > wrote: > > > > Hmm trying to work on the src code of `go doc` but every time I try to > compile a ./doc binary it uses other src code, it doesn't look in the > current

Re: [go-nuts] go build src code of `go doc`

2019-06-26 Thread Ian Lance Taylor
On Wed, Jun 26, 2019 at 1:39 PM Gert wrote: > > Hmm trying to work on the src code of `go doc` but every time I try to > compile a ./doc binary it uses other src code, it doesn't look in the current > directory am in, I have to force it `go build main.go` what going on here? > > gert@gert

[go-nuts] go build src code of `go doc`

2019-06-26 Thread Gert
Hmm trying to work on the src code of `go doc` but every time I try to compile a ./doc binary it uses other src code, it doesn't look in the current directory am in, I have to force it `go build main.go` what going on here? gert@gert ~/Desktop/go/src/cmd/doc:master> go build gert@gert

Re: [go-nuts] The Seven Finest Go Books (to popularize and 'socialize' Go).

2019-06-26 Thread Akram Ahmad
Michael, I'm delighted to read your gracious and thoughtful response. These ideas make me want to revisit and perhaps revise into a brand new write-up (all over again) something I had written a while ago! On

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread nicolas_boiteux via golang-nuts
Marvin, i just publish the last version of my files on git: can you please check them, and say me if the declaration/definition are ok ? I m not familiar with this cross langage compilation context/ https://github.com/code34/armago_x64/tree/32bits Le mercredi 26 juin 2019 20:10:55 UTC+2,

Re: [go-nuts] Why is the size of the official website release version so different from the size I built from the source code?

2019-06-26 Thread Ian Lance Taylor
On Wed, Jun 26, 2019 at 9:21 AM wrote: > > Taking the arm64 as an example. > The bin/go size I built from source code is about 14M, but the official > website one has 20M. > How is the Go release build ?I didn‘t find any information about this. I don't know why they would be different sizes.

[go-nuts] Go 1.13 Beta 1 is released

2019-06-26 Thread Andrew Bonventre
Hello gophers, We have just released go1.13beta1, a beta version of Go 1.13. It is cut from the master branch at the revision tagged go1.13beta1. Please try your production load tests and unit tests with the new version. Your help testing these pre-release versions is invaluable. Report any

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread Marvin Renich
* nicolas_boiteux via golang-nuts [190626 13:19]: > /* > #include > #include > #include > extern void __stdcall RVExtension(char *output, int outputSize, const char > *function); > */ > > //export RVExtensionVersion > func RVExtensionVersion(output *C.char, outputsize C.size_t) { >

Re: Re: [go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread Marcin Romaszewicz
No, it doesn't get all the data in the Next() call, it streams it incrementally from the DB. I've used it to stream gigabytes before, and they certainly didn't get buffered in RAM. On Wed, Jun 26, 2019 at 11:04 AM wrote: > Get all data in the first Next() call? or only get a batch? > >

Re: Re: [go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread sa517067
Get all data in the first Next() call? or only get a batch? At2019-06-26 21:19:07,Henrik Johanssondahankzter@gmail.comwrote: I am pretty sure it's the latter case with lazy loading when needed during the Next() call. On Wed, Jun 26, 2019 at 2:59 PM 杜沁园 wrote: When we operate with mysql

Re: [go-nuts] [ANN] Simple DNS Server implemented in Go

2019-06-26 Thread Daniel Lorch
Hi Matt I was not aware of this, thank you! I added a note in my repository. Daniel On Wednesday, June 26, 2019 at 2:54:39 AM UTC+2, Matt Harden wrote: > > I realize this is a learning exercise for you, but in case you're > interested, the DNS message types are implemented for you in >

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread nicolas_boiteux via golang-nuts
/* #include #include #include extern void __stdcall RVExtension(char *output, int outputSize, const char *function); */ //export RVExtensionVersion func RVExtensionVersion(output *C.char, outputsize C.size_t) { result := C.CString("Version 1.0") defer C.free(unsafe.Pointer(result))

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread Marvin Renich
* nicolas_boiteux via golang-nuts [190626 12:15]: > i have some news. > > With this kind of declaration > extern void __fastcall RVExtension(char *output, int outputSize, const char > *function){ > goRVExtension(output, outputSize, function); > }; > as you can see in error message this

[go-nuts] Why is the size of the official website release version so different from the size I built from the source code?

2019-06-26 Thread xuanjiazhen
Taking the arm64 as an example. The bin/go size I built from source code is about 14M, but the official website one has 20M. How is the Go release build ?I didn‘t find any information about this. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread nicolas_boiteux via golang-nuts
i have some news. With this kind of declaration extern void __fastcall RVExtension(char *output, int outputSize, const char *function){ goRVExtension(output, outputSize, function); }; // export goRVExtension func goRVExtension(output *C.char, outputsize C.size_t, input *C.char) { temp

Re: [go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread Henrik Johansson
I am pretty sure it's the latter case with lazy loading when needed during the Next() call. On Wed, Jun 26, 2019 at 2:59 PM 杜沁园 wrote: > When we operate with mysql with Go, as follow: > > > rows, err := db.Query() > > for rows.Next() { > . > } > > > When the driver get data? > > Get

[go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread 杜沁园
When we operate with mysql with Go, as follow: rows, err := db.Query() for rows.Next() { . } When the driver get data? Get all data at once when we call `Query`??? Or only get a batch of Data when we call `Next`, and get next batch of data when we run out of it -- You

Re: [go-nuts] Go runs multiple threads for a serial process

2019-06-26 Thread Robert Engels
The Go runtime has several threads, for GC, scheduler, etc. > On Jun 26, 2019, at 4:48 AM, Subramanian Sridharan > wrote: > > Hi guys > > Today while analyzing CPU usage of one of our processes written in go, I > noticed that there were multiple threads associated with the process which is

Re: [go-nuts] [cgo ] Export go function to C - illegal character

2019-06-26 Thread Amnon Baron Cohen
https://docs.microsoft.com/en-us/cpp/build/reference/decorated-names?view=vs-2019 -- 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] Go runs multiple threads for a serial process

2019-06-26 Thread Subramanian Sridharan
Hi guys Today while analyzing CPU usage of one of our processes written in go, I noticed that there were multiple threads associated with the process which is actually serial. (Doesn't make use of goroutines) I wanted to know if it was the expected behaviour or some issue in our service. So I

Re: [go-nuts] [ANN] Simple DNS Server implemented in Go

2019-06-26 Thread Olu Peter
Cool stuff. I’ll check it out and revert -- 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. To view this discussion on the