[go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread snmed
Hi rob Thanks for your response. I didn't know that trick, but it seems to me a little bit ugly to guard fields that way. I will stick to named initialisations and write it as a policy into the style guide. Cheers Am Donnerstag, 6. Juli 2017 02:26:27 UTC+2 schrieb rob rodgers: > > for some of

[go-nuts] Template func ParseFiles, parsing multiple files

2017-07-05 Thread Tong Sun
What would it happen if I pass two or more files to: func (*Template) ParseFiles func (t *Template ) ParseFiles(filenames ...string

Re: [go-nuts] Re: [ANN] go-dedup/simhash, enhanced Go simhash package

2017-07-05 Thread Damian Gryski
On Tuesday, July 4, 2017 at 10:56:35 PM UTC+2, Tong Sun wrote: > > Good to know. > > One question, I didn't find any help/text on how to use it -- why for so > many years, there is no usage help? My guess was that it is mainly for > internal use, not for the general public, but maybe I was

Re: [go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread Dan Kortschak
On Wed, 2017-07-05 at 17:26 -0700, rsr via golang-nuts wrote: > type bar struct { >    A int >    _ bool > } or `type bar struct { A int; _ [0]byte }` to avoid the additional byte use. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Google API Go Client - Get Admin.User.ExternalID mapped to type UserExternalId struct

2017-07-05 Thread chris . r . malek
To anyone who has worked with google.golang.org/api/admin/directory/v1 I am doing some automation with the Directory API. I get a user from the Gsuite Directory and want to get the user.ExternalID mapped into a type userExternalId. It seems Admin.User.ExternalID is defined as a interface{}

[go-nuts] Interrupting stdout writer for runaway child process on Windows

2017-07-05 Thread staticlimit
I have a customer that launched reg.exe with the /f switch and created a monster (it looks like reg.exe prompts for user input, reads stdin, sees the EOF and re-writes the prompt to stdout in a tight loop). I've tried several different ways to stop the write and ended up with a wrapper writer

[go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread rsr via golang-nuts
for some of our sensitive structures that are tricky and have multiple fields of the same type, there is a trick you can use: type bar struct { A int _ bool } see https://play.golang.org/p/rFKGoKq-S9 -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: The "call" function of Go template

2017-07-05 Thread Tong Sun
Thanks a lot! On Wednesday, July 5, 2017 at 8:16:09 PM UTC-4, Guy Allard wrote: > > Maybe take a look at: > > https://github.com/golang/go/issues/10653 > > and/or > > https://play.golang.org/p/Ka8bN3_V1f > > to understand what works, and what does not. > > > On Wednesday, July 5, 2017 at 11:58:02

[go-nuts] Re: The "call" function of Go template

2017-07-05 Thread Guy Allard
Maybe take a look at: https://github.com/golang/go/issues/10653 and/or https://play.golang.org/p/Ka8bN3_V1f to understand what works, and what does not. On Wednesday, July 5, 2017 at 11:58:02 AM UTC-4, Tong Sun wrote: > > Can somebody give an example for the following? I made several

Re: [go-nuts] Why the default format for nil slice and map is not nil?

2017-07-05 Thread David Collier-Brown
Hmmn: David J. Brown (my evil twin) was exceedingly good at unpainting himself from corners, did you know him? He as a Sun and SGI guy... Methinks merging two formats into (one better) one were amoung the things we did... -- You received this message because you are subscribed to the Google

[go-nuts] Capture test output per-function

2017-07-05 Thread buchanae . ohsu
In Funnel, we have a growing end-to-end test suite which has many test functions. https://github.com/ohsu-comp-bio/funnel/tree/master/tests/e2e When one test fails, Funnel's logs are dumped, and there are lots of them. Debugging tests has become difficult. As far as I can tell, go test

Re: [go-nuts] Why the default format for nil slice and map is not nil?

2017-07-05 Thread Rob Pike
It's probably just me not thinking things through in the early days of building the Go libraries. There's a lot of that. Hindsight is easy; foresight not so much. -rob On Wed, Jul 5, 2017 at 11:46 PM, Yann Salaün wrote: > Hello, > > I was surprised to realize today that

Re: [go-nuts] Uncontrolled map access can crash the program --- how?

2017-07-05 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Jul 5, 2017 at 12:29 PM Peter Kleiweg wrote: > From the faq: https://golang.org/doc/faq#atomic_maps > > ... uncontrolled map access can crash the program. > > In what situations does this apply? > > Can I have two goroutines reading a single map at the same time?

[go-nuts] Uncontrolled map access can crash the program --- how?

2017-07-05 Thread Peter Kleiweg
>From the faq: https://golang.org/doc/faq#atomic_maps ... uncontrolled map access can crash the program. In what situations does this apply? Can I have two goroutines reading a single map at the same time? Can I have one goroutine putting something in a map while at the same time another

[go-nuts] make.bash must be run from $GOROOT/src

2017-07-05 Thread Dave Cheney
The error message you received is correct; try something like this. (cd /usr/local/go/src && ./make.bash) -- 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: foo.Bar syntax clash - why?

2017-07-05 Thread ojucie
Everton, I think that is for the sake of simplicity. Let's consider C++ for a moment. In C++ you have a different operator for each of these situations: foo.Bar access to member Bar from object foo foo->Bar access to member Bar thru object pointer foo foo::Bar access to member Bar from the

Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy
okay the golang’s alternative for `optional->_32->Magic` is simply `optional._32.Magic.` So I’ve written my code regarding the about statement is given in https://play.golang.org/p/8sIAlxsmcj Thanks, solved. On Wednesday, July 5, 2017 at 7:02:10 PM UTC+5:30, Nathan Kerr wrote: > > Did

[go-nuts] Re: Switching from rsc.io/letsencrypt to x/crypto/acme/autocert

2017-07-05 Thread Diego Medina
yes, you provide the storage implementation and the library will use it when it needs to store/retrieve certs On Wednesday, July 5, 2017 at 10:48:26 AM UTC-4, Daniel Martí wrote: > > Hi all, > > One project I contribute to started using rsc.io/letsencrypt years ago. > Now that it's

Re: [go-nuts] Maximum number of requests per HTTP connection?

2017-07-05 Thread Kevin Malachowski
Creating an http.RoundTripper which was in charge of delegating to an http.Transport as well as swapping out to a new http.Transport when you want to swap underlying connections is probably what I'd try first. Cleaning up the old transport might be a little tricky if your application ever

[go-nuts] The "call" function of Go template

2017-07-05 Thread Tong Sun
Can somebody give an example for the following? I made several attempts but none is working. Thanks. call Returns the result of calling the first argument, which must be a function, with the remaining arguments as parameters. Thus "call .X.Y 1 2" is, in Go notation,

[go-nuts] gccgo on Solaris (I got it to work)

2017-07-05 Thread Stephen Bancroft
I know there may not be much demand for this these days, but I find myself in a job working with Solaris daily and I needed to have access to go. After many hours of searching the internet and many failed attempts I was finally able to compile gccgo for Solaris 11.3 (11.3.13.4). I'm posting

[go-nuts] Why the default format for nil slice and map is not nil?

2017-07-05 Thread Yann Salaün
Hello, I was surprised to realize today that the default format for a nil slice or map is the same as the default format for an empty one. However, this is not the case for a nil chan or func. See this playground link for an example: https://play.golang.org/p/OtoFRxjD61 I would be very

[go-nuts] make.bash must be run from $GOROOT/src

2017-07-05 Thread Kallen Ding
I want install golang on freebsd8.4 via source tarball, I execute ` *./all.bash*` after I extract the tar and into go/src, It occurs this: ``` /usr/local/go/src/all.bash make.bash must be run from $GOROOT/src ``` My go env is: ``` [root@freebsd /usr/local/go/src]# go env GOARCH="amd64"

[go-nuts] Switching from rsc.io/letsencrypt to x/crypto/acme/autocert

2017-07-05 Thread Daniel Martí
Hi all, One project I contribute to started using rsc.io/letsencrypt years ago. Now that it's recommended to switch to the latter, I've been looking into getting it done. But I'm confused as to what happened to Manager.Marshal and Manager.Unmarshal. We use these to store the state somewhere and

[go-nuts] foo.Bar syntax clash - why?

2017-07-05 Thread Everton Marques
If context is not given, I can't tell if foo.Bar() is a function of package foo or a method of variable foo. That is, dot is used both for package namespace and method call. Example: type T struct { } func (t T) Println(s string) { fmt.Println("method: " + s) } func main() {

[go-nuts] http2.Transport connections seem to occasionally get "stuck"

2017-07-05 Thread Andy Balholm
Users of github.com/andybalholm/redwood (an HTTP proxy) are running into an intermittent problem that I suspect is an HTTP/2 bug. But it is very difficult to pin down. The symptom reported by the customers is that, for an hour or two, all connections to Google servers through the proxy time

Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Nathan Kerr
Did you assign something to the pointer? My guess is that you did not, because the code compiles and then fails at runtime telling the pointer is NULL. On Wednesday, July 5, 2017 at 1:19:47 PM UTC+2, Manohar Reddy wrote: > > > fmt.Println(optional._32.Magic) // did not work for me: HOW TO

[go-nuts] Re: Do we need to close response.Body before closing it?

2017-07-05 Thread James Bardin
On Wednesday, July 5, 2017 at 6:50:10 AM UTC-4, Yulrizka wrote: > > > So in conclusion my question is do we need to always read the resp.Body > before closing it? > > Yes, you need to read the body to reuse the connection, otherwise there may be still be data waiting to be read. You dug

Re: [go-nuts] Re: Who wants to use Go to process your camera's raw files?

2017-07-05 Thread Jonathan Pittman
Unfortunately not from my end. I have had a lot going on at work and home. Time to work on this has escaped me. I did manage to move my initial prototyping work over to github.com/google/tiff and update the LICENSE to match the Go license. So, this is where we can make changes or blow it all

Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy
> fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS MAGIC VARIABLE This line returns null pointer de-reference at run time. Can you please guide me on how what is the alternative for optional->_32-> Magic in Golang? Thanks On Wednesday, July 5, 2017 at 4:42:07 PM UTC+5:30,

Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy wrote: > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS MAGIC VARIABLE Who wants to guess what does "did not work for me" mean without having the source code and the compiler output to look at? Please post

[go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Manohar Reddy
These are the things I have in C. IMAGE_OPTIONAL_HEADER *pe_optional(pe_ctx_t *ctx); typedef struct { uint16_t Magic; }IMAGE_OPTIONAL_HEADER_32; typedef struct { uint16_t type; IMAGE_OPTIONAL_HEADER_32 *_32; }IMAGE_OPTIONAL_HEADER; In c language to access Magic variable, I did

[go-nuts] Do we need to close response.Body before closing it?

2017-07-05 Thread Yulrizka
Hi I was reading this thread https://stackoverflow.com/questions/17948827/reusing-http-connections-in-golang and found this comment one interesting note is that the read step appears to be necessary and > sufficient. > The read-step alone will return the connection to the pool, but the

Re: [go-nuts] question about func type

2017-07-05 Thread 'Axel Wagner' via golang-nuts
Orthogonality means (roughly) "independent" in this context. I do agree with you, though, that the slide is incorrect. The spec defines type literals in the TypeLit production (search in page), which clearly only refers to composite types. The slides shouldn't talk

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:39 AM Darren Hoo wrote: > In https://talks.golang.org/2015/tricks.slide#5 says int is type literal, then you say int is named type. > > How can int be both type literal and named type while they are orthogonal? A type literal can be a named type

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wed, Jul 5, 2017 at 5:27 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > > >>> what is the relation between `type literal` and `named type`, > >> > >> Orthogonality. > > > > Then `int` is not named type. > > Please explain

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: >>> what is the relation between `type literal` and `named type`, >> >> Orthogonality. > > Then `int` is not named type. Please explain why do you think so. I don't get it. > `int` and `int64` are not the same in this

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wed, Jul 5, 2017 at 5:06 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > > > what is the relation between `type literal` and `named type`, > > Orthogonality. > Then `int` is not named type. `int` and `int64` are not the

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > what is the relation between `type literal` and `named type`, Orthogonality. > aren't they mutually exclusive? No. Otherwise `type T U` would be illegal. -- -j -- You received this message because you are

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wednesday, July 5, 2017 at 4:40:57 PM UTC+8, Jan Mercl wrote: > > On Wed, Jul 5, 2017 at 10:33 AM Darren Hoo > wrote: > > > So in https://talks.golang.org/2015/tricks.slide#5 > > > > Other examples of type literals are int and []string, > > > > is actually not

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 10:33 AM Darren Hoo wrote: > So in https://talks.golang.org/2015/tricks.slide#5 > > Other examples of type literals are int and []string, > > is actually not correct. The text is completely correct. Type literal is like a type expression. To

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
Thanks all. I got it. So in https://talks.golang.org/2015/tricks.slide#5 > Other examples of type literals are int and []string, is actually not correct. On Wednesday, July 5, 2017 at 3:59:57 PM UTC+8, Jan Mercl wrote: > > On Wed, Jul 5, 2017 at 9:54 AM Darren Hoo

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 9:54 AM Darren Hoo wrote: > which part did I misunderstand? 'u' and 'int64' are both named types. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] question about func type

2017-07-05 Thread 'Axel Wagner' via golang-nuts
Yes, V is a named type. The name of V is uint64, which is a predeclared identifier. On Wed, Jul 5, 2017 at 9:54 AM, Darren Hoo wrote: > Thank you all! > > But I still don't quite understand why the rule does not apply to the > first case? > > var a2 u = a1 > > x ---> a1 >

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
Thank you all! But I still don't quite understand why the rule does not apply to the first case? var a2 u = a1 x ---> a1 T ---> u V ---> uint64 V and T has the identical underlying types (ie, uint64) and V is not a named type (literal) . which part did I misunderstand? On Wednesday, July

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 9:17 AM Darren Hoo wrote: > f1's type is func(int), and f2's type is main.f, they are different types, does implicit conversion happen here? It's not a conversion. The rule is about assignability : "x's type

[go-nuts] question about func type

2017-07-05 Thread Dave Cheney
Func types are just regular types so the rules of assignability apply equally to them as any other type. x's type V and T have identical underlying types and at least one of V or T is not a named type. https://golang.org/ref/spec#Assignability -- You received this message because you are

[go-nuts] question about func type

2017-07-05 Thread Darren Hoo
package main type u uint64 type f func(int) func g(x int) { } func main() { var a1 uint64 = 1000 var a2 u = a1 //why this is not OK var f1 func(int) = g var f2 f = f1 //while this is allowed? f2(1) } f1's type is func(int), and f2's type is main.f, they are different types, does implicit

[go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread snmed
Okay thanks, as I supposed. Personally i used always named initialisation despite of the overhead, but sometimes I feel the urge to use the short unamed initialisation. ;-) Am Mittwoch, 5. Juli 2017 07:41:04 UTC+2 schrieb Tamás Gulácsi: > > Named. -- You received this message because you are