Re: [go-nuts] How to read a JSON Response body

2018-03-20 Thread st ov
? On Tuesday, March 20, 2018 at 11:26:18 AM UTC-7, Alex Efros wrote: > > Hi! > > On Tue, Mar 20, 2018 at 10:37:40AM -0700, st ov wrote: > > json.Unmarshal(resp.Body, ) > > This one is invalid. > > > json.NewDecoder(resp.Body).Decode() > > > >

[go-nuts] How to read a JSON Response body

2018-03-20 Thread st ov
For JSON responses, is it more appropriate to use json.Unmarshal(resp.Body, ) or json.NewDecoder(resp.Body).Decode() or b, _ := ioutil.ReadAll(resp.Body) json.Unmarshal(b, ) What are the uses for each? Does this differ from how you would read non-JSON responses? -- You received this

[go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-17 Thread st ov
Sunday, October 15, 2017 at 11:36:36 PM UTC+3, st ov wrote: >> >> A value sent through a channel can be read by only one reader, so once >> its read its no longer available to other readers is that right? >> >> In what ways can I pass/communicate/distribute a value thro

[go-nuts] How to pass a value to multiple readers of a shared channel

2017-10-15 Thread st ov
A value sent through a channel can be read by only one reader, so once its read its no longer available to other readers is that right? In what ways can I pass/communicate/distribute a value through a channel and have it shared across an unknown number of readers? -- You received this message

[go-nuts] Golang dep missing vendor dependencies

2017-09-06 Thread st ov
I'm not seeing dep ensure the transitive dependencies of my vendored packages. How do I ensure that all dependencies are downloaded? -- 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

[go-nuts] Re: Dave Cheney's "Practical Go" book

2017-09-05 Thread st ov
Don't know, hope @Dave Cheney will be able to answer that. On Monday, September 4, 2017 at 6:03:18 PM UTC-7, chou wrote: > > I want to buy one, is it released out? > > 在 2017年9月5日星期二 UTC+8上午7:41:36,st ov写道: >> >> Any information on the contents and a release date? >>

Re: [go-nuts] Re: What are test binaries?

2017-09-05 Thread st ov
Thanks! On Tuesday, September 5, 2017 at 2:14:07 AM UTC-7, Peter Waller wrote: > > On 5 September 2017 at 06:35, Volker Dobler > wrote: > >> A "test binary" is a normal binary compiled by go test including the test >> function >> from the *_test.go files which executes

[go-nuts] What are test binaries?

2017-09-04 Thread st ov
And how do they differ from normal binaries? -- 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, visit

[go-nuts] Dave Cheney's "Practical Go" book

2017-09-04 Thread st ov
Any information on the contents and a release date? Couldn't find any details on O'reilly, Amazon or dave.cheney.net. -- 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

[go-nuts] Custom ServeMux and pprof

2017-08-28 Thread st ov
How do you add pprof to a custom ServeMux? https://golang.org/pkg/net/http/#ServeMux Its my understanding that the following import only adds handlers to the default mux. import _ "net/http/pprof" -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Using pprof on publicly accessible servers

2017-08-28 Thread st ov
It's recommended to add pprof to servers import _ "net/http/pprof" Is this true even for publicly exposed servers? How do you limit access? How useful is pprof for clusters since it only profiles a single server? -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: How do you test a server?

2017-07-23 Thread st ov
Thanks for the suggestions, but that framework is for mocking a server right? What if what I want to test is a server and endpoints I developed? On Friday, July 21, 2017 at 1:24:23 AM UTC-7, Simon Ritchie wrote: > > My scaffolding tool generates a web server and some unit and integration >

[go-nuts] Re: How do you test a server?

2017-07-20 Thread st ov
Thats a great resource, thank you! Also does the htttptest.Server mock out a server so that you can test clients? What if I want to test my own server? On Wednesday, July 19, 2017 at 10:07:44 AM UTC-7, Jérôme LAFORGE wrote: > > One of my favorite resource can be found here about testing

[go-nuts] How do you test a server?

2017-07-19 Thread st ov
When creating a simple server using http.Server and http.ServeMux, how do you test it? What do you do for unit tests? integration tests? Do you mock requests to each handler and check the response? How? How do you test peformance and requests per second? -- You received this message because

Re: [go-nuts] How do you create and use shared libraries in Go?

2017-06-26 Thread st ov
:47:14 AM UTC-7, Peter Mogensen wrote: > > > > On 2017-06-26 09:37, st ov wrote: > > Ruby has Gems and .NET has DLLs. > > How do you package and share libraries in Go? > > Gems are mainly source files, right? ... Using > source libraries in Go is relatively strai

[go-nuts] How do you create and use shared libraries in Go?

2017-06-26 Thread st ov
Ruby has Gems and .NET has DLLs. How do you package and share libraries in Go? -- 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

Re: [go-nuts] How to manage multiple versions of Go?

2017-06-26 Thread st ov
as 100% > compatibility. So far, compatibility issues have been no problem *for me*, > but I can only speak for myself. > > > On 25. Jun 2017, at 20:16, st ov <so.q...@gmail.com > wrote: > > Could you go into a bit more detail on how you would setup a local docker >

[go-nuts] Re: How to manage multiple versions of Go?

2017-06-25 Thread st ov
robably use Docker > for that. > > Advantages of using Go within a Docker container: > > * No accidental mixing of Go versions > * No multi-GOPATH hassle > * Can be removed cleanly when not needed anymore. > > On Saturday, June 24, 2017 at 10:12:38 PM UTC+2, st ov wr

[go-nuts] How to manage multiple versions of Go?

2017-06-24 Thread st ov
Do you use gvm? https://github.com/moovweb/gvm Is there a simpler way? How do you avoid conflicts with Homebrew? Should I not run 'brew install go'? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Are there any implicit type conversions in Go?

2017-05-13 Thread st ov
Go appears to be very strict when using types. Even aliases need to be explicitly cast. Are there any contexts where types are implicitly cast? Or must all type conversions be specified? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Is it ok to separate Open and Close logic?

2017-05-10 Thread st ov
Most examples of opening and closing a file have both calls in the same function func DoFileStuff() { file, _ := os.Open("file") defer file.Close() // do stuff with file } This makes sure any open file is closed. But how common is it to separate that logic into functions? Should this be

[go-nuts] Re: Are Go test methods run serially?

2017-05-08 Thread st ov
Thanks yet again for clarifying and correcting my assumptions. So within a single package tests are run serially, but I can't rely on that when testing multiple packages. On Sunday, May 7, 2017 at 8:04:52 PM UTC-7, Dave Cheney wrote: > > The post over on stack overflow is confused. The

[go-nuts] Are Go test methods run serially?

2017-05-07 Thread st ov
Go test methods run in separate goroutines but those routines are run serially right? So variable assignments shouldn't get stomped by other tests? I saw a comment saying they're *concurrent*, but not *parallel* by default.

[go-nuts] Re: Fully-qualified import paths and Pull Requests

2017-05-07 Thread st ov
Thanks for correcting my concerns! On Thursday, May 4, 2017 at 8:52:02 PM UTC-7, Dave Cheney wrote: > > > > On Friday, 5 May 2017 13:37:26 UTC+10, st ov wrote: >> >> By "fork" I mean in the GItHub sense, the forking of original project >> *github.com/orig

[go-nuts] Re: Fully-qualified import paths and Pull Requests

2017-05-04 Thread st ov
By "fork" I mean in the GItHub sense, the forking of original project *github.com/original/foo* through their console so that *github.com/me/foo* is created. And "clone" would be running "git clone https://github.com/original/foo.git; on my local machine so I have a local copy of the original

[go-nuts] Re: Fully-qualified import paths and Pull Requests

2017-05-03 Thread st ov
Should the source repo be cloned or forked first? Or does it not matter? I was thinking there could be an issue with someone pushing a change after its cloned but before its forked. On Tuesday, May 2, 2017 at 11:55:41 PM UTC-7, Nathan Kerr wrote: > >

[go-nuts] Re: Fully-qualified import paths and Pull Requests

2017-05-03 Thread st ov
On Wednesday, May 3, 2017 at 7:33:49 AM UTC-7, st ov wrote: > > Thanks, if I read that right the post just rehashes the workflow for > working with remotes with git and go get. > > The question I have concerns the import path in the code. > > If I fork, *github.com/origina

[go-nuts] Re: Fully-qualified import paths and Pull Requests

2017-05-03 Thread st ov
Thanks, if I read that right the post just rehashes the workflow for working with remotes with git and go get. The question I have concerns the import path in the code. If I fork, *github.com/original/foo* clone it locally to, *github.com/me/foo* Add *github.com/me/foo/internal/bar/bar.go* and

[go-nuts] Fully-qualified import paths and Pull Requests

2017-05-02 Thread st ov
How should import paths be handled with regard to pull requests? For example, I fork a project and add an internal package. Convention says I should use the fully-qualified import path in my own project. When creating a pull request this import path would need to be updated to point to the

Re: [go-nuts] Large GC pauses with large map

2017-04-21 Thread st ov
amazing, Thank you for that detailed breakdown! On Friday, April 21, 2017 at 10:08:02 AM UTC-7, Jesper Louis Andersen wrote: > > On Fri, Apr 21, 2017 at 5:58 PM st ov <so.q...@gmail.com > > wrote: > >> @Jesper, curious how you determined that? >> Is

Re: [go-nuts] Re: Possible to run tests against a specific Go binary?

2017-04-21 Thread st ov
Thank you Ian for providing those details and for pointing me to the code in the source to reference. I'll have a look and respond back if I have any questions. On Friday, April 21, 2017 at 1:18:22 PM UTC-7, Ian Lance Taylor wrote: > > On Fri, Apr 21, 2017 at 12:37 PM, st ov

Re: [go-nuts] Re: Constructor return advice

2017-04-21 Thread st ov
Thanks for the confirmation and advice! On Friday, April 21, 2017 at 1:29:02 PM UTC-7, Alan Donovan wrote: > > On 21 April 2017 at 15:26, st ov <so.q...@gmail.com > wrote: >> >> When deciding between method receivers, any advice on how to choose which >> to use? &

Re: [go-nuts] Re: Possible to run tests against a specific Go binary?

2017-04-21 Thread st ov
-7, Ian Lance Taylor wrote: > > On Fri, Apr 21, 2017 at 9:30 AM, st ov <so.q...@gmail.com > > wrote: > > Is it not possible? The doc seems to say that 'go test' recompiles each > > package tested > > https://golang.org/cmd/go/#hdr-Test_packages > > `go t

[go-nuts] Re: Possible to run tests against a specific Go binary?

2017-04-21 Thread st ov
Is it not possible? The doc seems to say that 'go test' recompiles each package tested https://golang.org/cmd/go/#hdr-Test_packages On Thursday, April 20, 2017 at 10:00:24 AM UTC-7, st ov wrote: > > As part of a build pipeline, I want to initially artifact the Go binary to > send th

[go-nuts] Constructor return advice

2017-04-21 Thread st ov
In general, is it advisable to return pointers to newly constructed instances when using constructors? Would it matter more for types that don't have members of composite types slice and maps? So in the following example, https://play.golang.org/p/sWTWkHfZfB Bar is made up of mostly strings,

Re: [go-nuts] Large GC pauses with large map

2017-04-21 Thread st ov
@Jesper, curious how you determined that? Is it in the spec? or the source? Or is this a common GC pattern that you presume is being used? On Thursday, April 20, 2017 at 7:01:03 AM UTC-7, Jesper Louis Andersen wrote: > > A somewhat common culprit seems to be the following case: > > 1. In

[go-nuts] Possible to run tests against a specific Go binary?

2017-04-20 Thread st ov
As part of a build pipeline, I want to initially artifact the Go binary to send through all the stages from development to production. How can I run a set of tests (*_test.go) against this one binary? Can I only have blackbox tests or is whitebox possible? Or will the approach need to be, to

[go-nuts] Re: Best practice for Method Receivers

2017-04-20 Thread st ov
ead to field > result. > > There is a data race on rpc.result > > On Sunday, April 2, 2017 at 11:57:59 PM UTC+2, st ov wrote: >> >> Could you explain how this is a race condition? >> Running it in the playground appears to succeed, >> https://play.golang.org/p

[go-nuts] Is everything passed as a value in Go?

2017-04-18 Thread st ov
I read everything is pass-by-value in Go, is that correct? What does it encompass? Are there any exceptions? Does that mean the following: int passes full integer byte value float64 passes full float byte value string passes full string []byte value slice passes pointer value to slice in memory

[go-nuts] Re: Best practice for Method Receivers

2017-04-02 Thread st ov
receivers, as seen here: > https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race > > > On Friday, March 24, 2017 at 6:20:06 PM UTC-7, st ov wrote: >> >> Is it idiomatic to mix-&-match pointer and value method receivers for a >> given type? >> or in

[go-nuts] Best practice for Method Receivers

2017-03-24 Thread st ov
Is it idiomatic to mix-&-match pointer and value method receivers for a given type? or in *general*, if a single method requires a pointer receiver than *all methods* should take a pointer, regardless if a value receiver is appropriate? For example, should Foo.SetVal also be a pointer

Re: [go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-13 Thread st ov
just a thought experiment :) On Monday, March 13, 2017 at 12:20:57 AM UTC-7, Jan Mercl wrote: > > On Mon, Mar 13, 2017 at 8:05 AM st ov <so.q...@gmail.com > > wrote: > > > I know it can be accessed the question relates to this > > > http://stackoverflow.

Re: [go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-13 Thread st ov
itself > as usual, no reflect needed. > > On Mon, Mar 13, 2017, 01:37 st ov <so.q...@gmail.com > wrote: > >> Thanks! >> anyway to get a reference to that new array without using reflect? >> >> >> >> >> On Sunday, March 12, 2017 at 12:13:03 PM

Re: [go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-12 Thread st ov
Thanks! anyway to get a reference to that new array without using reflect? On Sunday, March 12, 2017 at 12:13:03 PM UTC-7, Jan Mercl wrote: > > On Sunday, March 12, 2017 at 11:49:33 AM UTC-7, st ov wrote: > > > What happens when appending to a slice exceeds the b

[go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-12 Thread st ov
:33 AM UTC-7, st ov wrote: > > What happens when appending to a slice exceeds the backing capacity? > > https://play.golang.org/p/mVezWL4Cbe > > In the example given, appending within capacity on line 20 modifies the > backing array at the successive index. > But on line 26

[go-nuts] What happens when appending to a slice exceeds the backing capacity?

2017-03-12 Thread st ov
What happens when appending to a slice exceeds the backing capacity? https://play.golang.org/p/mVezWL4Cbe In the example given, appending within capacity on line 20 modifies the backing array at the successive index. But on line 26, when appending exceeds the capacity, the backing array is no

Re: [go-nuts] How to render a single webpage without templates?

2017-03-09 Thread st ov
Oh I see, so I need to treat all the elements as individual requests and specifically handle each. Thanks! On Thursday, March 9, 2017 at 12:59:13 AM UTC-8, Axel Wagner wrote: > > By writing the corresponding code :) For example: > > package main > > import ( > "log" > "net/http" > ) > > func