[go-nuts] What is the correct way to implement testing/quick.Generator?

2017-01-19 Thread Patrick Redmond
I was trying to implement a custom `Generator` for a struct for use with `testing/quick.Check`. The property function passed to `testing/quick.Check` defines the type of its own arguments, so I need to make sure the custom `Generator` function will be used in either the case where the property

Re: [go-nuts] How to seek in file use bufio.Reader?

2017-01-19 Thread Konstantin Khomoutov
On Wed, 18 Jan 2017 23:35:30 -0800 (PST) hui zhang wrote: > I am using bufio.Reader and binary.Read > to read binary from file, I want to seek in the file or bufio.Reader > Below code does not work > > fi.Seek(0, os.SEEK_SET) Does not work for bufio.Reader > > >

Re: [go-nuts] why there are so many ways to read file

2017-01-19 Thread Konstantin Khomoutov
On Thu, 19 Jan 2017 00:05:46 -0800 (PST) hui zhang wrote: > check below link > > http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file-using-golang > > It offer 3 ways. > os > *bufio* > *ioutil* There's just a single way to read a file -- using the

[go-nuts] Can't find textflag.h in Fedora 25 when getting gonum/floats

2017-01-19 Thread Alessandro Re
Hello, few months back, on Fedora 23, I wrote a code that used gonum/floats. Now on Fedora 25 I was trying to use that code again, but I fail in building it because a certain header file can't be found when getting gonum/floats. Here some details: MyGo$ go get github.com/gonum/floats #

[go-nuts] Re: Can't find textflag.h in Fedora 25 when getting gonum/floats

2017-01-19 Thread Dave Cheney
It looks like you've install gccgo, not go (sometimes called golang-go by operating system vendors). If you uninstall gccgo and install Go from the website, https://golang.org/dl/, it should work fine. On Thursday, 19 January 2017 22:03:10 UTC+11, Alessandro Re wrote: > > Hello, > few months

[go-nuts] Re: Bufio vs. Writing to Disk

2017-01-19 Thread Frank Davidson
Thanks, Tomas! Very helpful! Do you know if it's important to run Flush() on the gzip writer? Frank On Thursday, January 19, 2017 at 12:00:44 AM UTC-5, Tamás Gulácsi wrote: > > The bufio.NewWriter is unneeded here, as both the gzip.Writer and > csv.Writer are buffered. > > The concept of

[go-nuts] Re: how to seek in file using go

2017-01-19 Thread C Banning
Why rd := bufio.NewReader(fi)? 'fi' implements io.Reader. Try: err = binary.Read(fi, binary.LittleEndian, ) instead. Then fi.Seek(...) will manipulate your io.Reader. [An example: https://github.com/clbanning/rfile/blob/master/reverse.go#L57.] On Wednesday, January 18, 2017 at 11:22:48

[go-nuts] Re: Bufio vs. Writing to Disk

2017-01-19 Thread Tamás Gulácsi
2017. január 19., csütörtök 15:10:56 UTC+1 időpontban Frank Davidson a következőt írta: > > Thanks, Tomas! > > Very helpful! > > Do you know if it's important to run Flush() on the gzip writer? > > You must either call .Flush, or .Close at the end - and also Close the file, and check both

[go-nuts] JSON decode streaming : Go forward when format is not json

2017-01-19 Thread Thomas Solignac
Hello, I build a service receiving Json from websocket. I use json decode. I want my service to be robust ! *var tmp interface{}* *err = this.reader.Decode()* My problem is : When I got some error here, I came to infinite loop, because the decoder doesn't go forward. It seems that it is

[go-nuts] Go 1.8 Release Candidate 2 is released

2017-01-19 Thread Chris Broadfoot
Hello gophers, We have just released go1.8rc2, a release candidate of Go 1.8. It is cut from release-branch.go1.8 at the revision tagged go1.8rc2. Thank you to everyone who has helped to test Go 1.8 so far. We still need more people to test, especially on production workloads. Your help is

Re: [go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread Edward Muller
No, it is not.* * appending can replace the underlying array, so in certain situations it can be, but that's more by accident IMO so just don't rely on that. On Thu, Jan 19, 2017 at 1:43 PM xiaohai dai wrote: > I know that map in golang is not thread-safe for writing. >

Re: [go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread Jason Stillwell
But it returns the new slice. On Thursday, January 19, 2017 at 2:40:30 PM UTC-8, freeformz wrote: > > No, it is not.* > > * appending can replace the underlying array, so in certain situations it > can be, but that's more by accident IMO so just don't rely on that. > > On Thu, Jan 19, 2017 at

Re: [go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread Edward Muller
Which may or may not have the same backing array. https://play.golang.org/p/GsffpJc1cX PS: I probably should have just said 'no. slices are not "thread-safe"'. I have complicated the issue to no benefit. On Thu, Jan 19, 2017 at 2:56 PM Jason Stillwell wrote: > But it

Re: [go-nuts] Program design question

2017-01-19 Thread Shawn Milochik
If you're an experienced developer, just run with it. You'll see the seams and figure out where to split it. Many thinkers in the microservice space consider starting a new application with a monolith and breaking it up when the partitions present themselves as better than trying to start from

[go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread xiaohai dai
I know that map in golang is not thread-safe for writing. However, I'm not sure slice/array is thread-safe for writing. I have searched the related posts and blogs in google, but find no unambiguous statement. Thanks in advance! -- You received this message because you are subscribed to the

[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-19 Thread Jordan Krage
Would a simple single method interface meet your needs? type fooer interface { foo() bool } func (a *A) foo() bool { ... } func bar(f fooer) { if f.foo() { ... } } func main() { a := { ... } bar(a) } On Wednesday, January 18, 2017 at 8:55:07 PM UTC-6, Bryan Chan

[go-nuts] [ANN] Rapid API tool: AWS Lambda + API Gateway + Go (Aegis)

2017-01-19 Thread Tom Maiaroto
Hi all, I've advertised this tool and wrote a blog post about it even, but never really announced it here or in Slack. I thought a forum would be a better place for feedback than Twitter or something so I figured I'd post here. You can find the project here: https://github.com/tmaiaroto/aegis

Re: [go-nuts] JSON decode streaming : Go forward when format is not json

2017-01-19 Thread nostgard
A partial stream must still be a valid stream. Once the stream is in an invalid state, the decoder doesn't know how to proceed. Since none of the value types that can be represented by JSON can begin with the letter "T", the stream can be considered invalid soon as the decoder encounters that

[go-nuts] go ssh package packet lenght too large

2017-01-19 Thread saptah
Hi guys, I'm doing a little script to backup Huawei Maquines. This script connects via SSH to a Huawei device, and runs several commands. http://pastebin.com/mFUKGcXn I have this exact script running fine in other hardware (same hardware and software) but In one them, i keep getting this

[go-nuts] Re: Can somebody explain the importance of 'select'?

2017-01-19 Thread Thomas Solignac
Let's say you make a sudoku solver, as fast as possible. You have a multicore computer. If the disk read or parsing is slow, you are going to prepare sudoku files in 3 goroutines, let's say. And the 4th thread (the main thread, let's say) will solve them. How the main thread can get sudoku to

[go-nuts] Re: Can somebody explain the importance of 'select'?

2017-01-19 Thread Chris Hines
I believe the primary reason why select must be in the language is because it integrates tightly with goroutine scheduling to efficiently block, and then wake up when one of its channel operations can complete. On Thursday, January 19, 2017 at 12:33:38 PM UTC-5, John C. wrote: > > On several

Re: [go-nuts] JSON decode streaming : Go forward when format is not json

2017-01-19 Thread Tamás Gulácsi
2017. január 19., csütörtök 18:55:22 UTC+1 időpontban Thomas Solignac a következőt írta: > > Thank you for answer. > > I think that this behaviour is approriate too, considering this. > However, something remains strange. > > *How could the streamer know the difference between a partial stream

[go-nuts] Re: Program design question

2017-01-19 Thread Diego Medina
If you were planning on running each binary on different servers, then it would somewhat make sense (but you should really measure to see how CPU heavy the processing is). But if you are planning on putting both binaries on the same server, you may as well just have one binary. Otherwise both

Re: [go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread xiaohai dai
I see! Thank you! 在 2017年1月20日星期五 UTC+8上午6:40:30,freeformz写道: > > No, it is not.* > > * appending can replace the underlying array, so in certain situations it > can be, but that's more by accident IMO so just don't rely on that. > > On Thu, Jan 19, 2017 at 1:43 PM xiaohai dai

Re: [go-nuts] Is slice in golang thread-safe for appending

2017-01-19 Thread xiaohai dai
Wonderful! The example in ttps://play.golang.org/p/GsffpJc1cX is great. Thank you 在 2017年1月20日星期五 UTC+8上午7:04:02,freeformz写道: > > Which may or may not have the same backing array. > > https://play.golang.org/p/GsffpJc1cX > > PS: I probably should have just

[go-nuts] Question about data race

2017-01-19 Thread xiaohai dai
I am reading "Data Race Detector" from Godoc. However, I'm confused by the example: Primitive unprotected variable displayed in the post. I don't know why this example could lead to data race. Any help will be

[go-nuts] go ssh package packet lenght too large

2017-01-19 Thread Dave Cheney
While I appreciate you writing this in Go, wouldn't this scripting be better done in shell? What's likely happening is the SSH server on your device only supports older insecure algorithms, which ironically are more common amongst security hardware. -- You received this message because you

[go-nuts] Re: mgo r2015.12.06 is out

2017-01-19 Thread Davis Ford
Just in case anyone else lands here, Mongo doesn't support mixed mode replica set with 2.6.x and 3.2.x -- I learned that the hard way, adding a new 3.2 member to the replica set to work on upgrading the nodes. I had to remove that node, and build all new 3.0 nodes; now I'm in the process of

Re: [go-nuts] Question about data race

2017-01-19 Thread Ian Lance Taylor
On Thu, Jan 19, 2017 at 7:05 PM, xiaohai dai wrote: > I am reading "Data Race Detector" from Godoc. > However, I'm confused by the example: Primitive unprotected variable > displayed in the post. I don't know why this example could lead to data > race. The assumption is

Re: [go-nuts] Question about data race

2017-01-19 Thread xiaohai dai
Thanks for your reply. However, I don't think reading and writing w.last concurrently will lead to data race. In my opinion, concurrent writing to w.last may lead to data race, but reading and writing concurrently here may not. Look forward to your reply again. 在 2017年1月20日星期五

Re: [go-nuts] Question about data race

2017-01-19 Thread Ian Lance Taylor
On Thu, Jan 19, 2017 at 9:19 PM, xiaohai dai wrote: > > Thanks for your reply. > However, I don't think reading and writing w.last concurrently will lead to > data race. > In my opinion, concurrent writing to w.last may lead to data race, but > reading and writing

Re: [go-nuts] Is there any import path limitation when using go:linkname localname importpath.name?

2017-01-19 Thread Ian Lance Taylor
On Wed, Jan 18, 2017 at 6:55 PM, Cholerae Hu wrote: > I'm trying to play with go:linkname, and I wrote a demo for this. > > directory structure: > > [test]$ tree > . > ├── main.go > ├── pri > │ └── a.go > └── pub > ├── issue15006.s > └── b.go > > a.go: > > package

Re: [go-nuts] Can somebody explain the importance of 'select'?

2017-01-19 Thread Ian Lance Taylor
On Thu, Jan 19, 2017 at 9:33 AM, John C. wrote: > On several occasions the Go designers have alluded to the fact that the > 'select' mechanism and the fact that it's built in to the language are very > important for concurrency (can't seem to find references). While I >

[go-nuts] Re: [ANN] Rapid API tool: AWS Lambda + API Gateway + Go (Aegis)

2017-01-19 Thread Tom Maiaroto
Yes, you still need to use a wrapper of some sort. I chose Node.js, but am also thinking about using Python to see which is faster. That said, your Go Lambdas will typically (in every example of substance I've seen) will run faster than Node.js Lambdas. The wrapper is a bummer from an

Re: [go-nuts] JSON decode streaming : Go forward when format is not json

2017-01-19 Thread Thomas Solignac
Thank you for answer. I think that this behaviour is approriate too, considering this. However, something remains strange. *How could the streamer know the difference between a partial stream and a not JSON string ?* Because here, the message sent is just "TEST". And the error is : "invalid

[go-nuts] Can somebody explain the importance of 'select'?

2017-01-19 Thread John C.
On several occasions the Go designers have alluded to the fact that the 'select' mechanism and the fact that it's built in to the language are very important for concurrency (can't seem to find references). While I understand just fine how to use select/goroutines/channels, the overarching

Re: [go-nuts] JSON decode streaming : Go forward when format is not json

2017-01-19 Thread Jakob Borg
You're decoding JSON objects from a stream. Knowing where the next object starts requires knowing where the current one ends. If the current JSON object can't be decoded, the decoder doesn't know where it ends, and it can't proceed to the next one. Closing the connection is probably

Re: [go-nuts] Is there any import path limitation when using go:linkname localname importpath.name?

2017-01-19 Thread Cholerae Hu
I edited my code to import test/pri in test/pub: pri/a.go: package pri import ( "fmt" ) const ( Dummy = 1 ) func rua() int64 { fmt.Println("rua in pri") return int64(1) } pub/b.go: package pub import ( "unsafe" pri "test/pri" ) var _ = unsafe.Sizeof(0) var _ =

[go-nuts] Type declarations and the underlying type's methods

2017-01-19 Thread Viktor Kojouharov
Hello, Considering how easy it is to create new types based on underlying types, how come the newly created ones do not delegate method calls to their underlying types? Consider the following example: https://play.golang.org/p/Zs7Ve8ECk2 In the example, calling `b.num()` directly will not