Re: [go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-23 Thread roger peppe
This is a bug that has been fixed on Go tip by https://go-review.googlesource.com/c/go/+/65550. On 23 January 2018 at 00:45, Josh Humphries wrote: > I think have misspoken. Even though the field's name appears exported via > reflection (it has a name that starts with a

[go-nuts] [ANN] GoCV v0.8.0 is out, now with Tensorflow and Caffe support

2018-01-23 Thread Ron Evans
Hello, fellow gophers Just wanted to let you know that the new version of GoCV (https://gocv.io) is out, now with support for Tensorflow, Caffe, and much more. Blog post here: https://gocv.io/blog/2018-01-23-go-opencv-tensorflow-caffe/ Our showcase example for this release is performing

[go-nuts] Re: Is it possible to determine total number of bytes read/written for an HTTP request? (including headers)

2018-01-23 Thread aroman
Huh. Is this actually not possible? (That is, without modifying net/http directly?) On Friday, January 19, 2018 at 12:47:06 PM UTC-7, Augusto Roman wrote: > > I'm interested in tracking total bandwidth on a per-request basis. It's > easy to intercept the ResponseWriter and track the number of

[go-nuts] gofmt rewrite rules

2018-01-23 Thread Chris Hopkins
Hi, I'm tidying up some code and I think this would be a great use for gofmt's rewrite capabilities, but I can't make it work. I have some code where error checking is missing. In the code every instance of Set returns an error value that is not checked, so I assumed I could write: gofmt -w -r

Re: [go-nuts] gofmt rewrite rules

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 2:03 PM Chris Hopkins wrote: > gofmt -w -r 'a.Set(b,c) -> err:=a.Set(b,c)\nif err != nil{log.Fatal("Set Error",err)}' I think the -r flag can handle only forms like 'expr1 -> expr2', but in this case expr2 is a statement. To my surprise I cannot

Re: [go-nuts] gofmt rewrite rules

2018-01-23 Thread Sebastien Binet
Wouldn't this be more a job for 'eg' instead? sent from my droid On Jan 23, 2018 2:03 PM, "Chris Hopkins" wrote: > Hi, > I'm tidying up some code and I think this would be a great use for gofmt's > rewrite capabilities, but I can't make it work. I have some code where >

[go-nuts] How to get mount point or device name by directory?

2018-01-23 Thread Matrix Neo
Hi, everybody: I want to get the mount point or device name (like /dev/sda1) by the directory name. I try my best only to find syscall.Stat_t struct but there is no field to point the information i need. So is there any way to implement this ? -- You received this message because you

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread dc0d
The third option was the expected one. Locking aside (as the thought line behind the original question), the time spent on preparing/calculating a result value to be sent to a channel, is not directly relevant to the case for nil channels - which were expected to get ignored. I do not

Re: [go-nuts] Re: Experience Report building OCR in Go

2018-01-23 Thread Sokolov Yura
+1 for map's zero value. Huge inconsistency in a language. I think, it were made for speed: map is just a pointer (to hidden struct). Zero-map is just nil pointer. To make zero-value mutable there should be assignment to a pointer on every access. More over, map has reference identity ie it is

[go-nuts] Re: Gorilla Sessions Example Question

2018-01-23 Thread aikiav8r
Can I assume that the Set-Cookie is the creation of a new session? Odd that is the example. [ ~]$ curl -i --cookie "cookie-name=MTUxNjY3NTcxN3xEdi1CQkFFQ180SUFBUkFCRUFBQUpmLUNBQUVHYzNSeWFXNW5EQThBRFdGMWRHaGxiblJwWTJGMFpXUUVZbTl2YkFJQ0FBRT18M0_ZIEv6dOYHWKyD3GdEJhqUM8KvUJN-i4KIu7opWJA=;"

[go-nuts] golang with single-page HTML.

2018-01-23 Thread jackteeter1945
i have a few .go programs that use the old /, /index, /about, /login, /signup etc. I have been trying to use the SPA single-page HTML. But I cannot figure out how to use SPA with my golang modules. Anyone have any simple examples of this? If I had my druthers, I would try use angular5 for

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread 'Axel Wagner' via golang-nuts
I don't think you can confidently make the claim 3. Nothing in the spec (or basic logic) says, that a send on a nil-channel gets ignored, does it? The case-block never gets executed, yes, but that's a consequence of the effects a) send on a nil-channel blocks for ever and b) select waits for a

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread Marvin Renich
* dc0d [180123 08:45]: > Can anybody help me understand the reason? (It's in the spec. That's not > the reason) > > On Sunday, December 31, 2017 at 10:14:31 AM UTC+3:30, dc0d wrote: > > > > Assume there is this select statement: > > > > for { > > select { > >

Re: [go-nuts] [ANN] GoCV v0.8.0 is out, now with Tensorflow and Caffe support

2018-01-23 Thread Ranjib Dey
Awesom effort Rob. Thank you for all the work you put in for gocv and gobot. On Tue, Jan 23, 2018 at 12:57 AM Ron Evans wrote: > Hello, fellow gophers > > Just wanted to let you know that the new version of GoCV (https://gocv.io) > is out, now with support for Tensorflow,

[go-nuts] TLS mutual auth: trusting a single client certificate?

2018-01-23 Thread snmed
Hi As far as I understand, you can set this function VerifyPeerCertificate in the tls config and then verify the thumbprint of the client certificate. This method is only called, when the client has a valid certificate. Cheers Sandro -- You received this message because you are subscribed

Re: [go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-23 Thread roger peppe
Have you tried out the behaviour on Go tip (or the go 1.10 beta)? On 23 Jan 2018 14:31, "Josh Humphries" wrote: Roger, I don't believe that patch will change behavior. See my last message: the fields appear to be unexported according to reflection. That patch has the

[go-nuts] TLS mutual auth: trusting a single client certificate?

2018-01-23 Thread Jean-Francois Bibeau
Hi! I've had a successful TLS mutual authentication client/server setup in Go for a while, but now looking to make some small tweaks. Specifically, I'm wondering if there is a way to require only a specific client certificate for mutual auth. I'm currently using something like this: // Load

Re: [go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-23 Thread dc0d
Did not try that and changed that instance of this code. On Tuesday, January 23, 2018 at 9:04:36 PM UTC+3:30, rog wrote: > > Have you tried out the behaviour on Go tip (or the go 1.10 beta)? > > On 23 Jan 2018 14:31, "Josh Humphries" > wrote: > > Roger, > I don't believe

Re: [go-nuts] How to get mount point or device name by directory?

2018-01-23 Thread Ian Lance Taylor
On Mon, Jan 22, 2018 at 10:11 PM, Matrix Neo wrote: > > I want to get the mount point or device name (like /dev/sda1) by the > directory name. I try my best only to find syscall.Stat_t struct but there > is no field to > point the information i need. So is there any

Re: [go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-23 Thread Josh Humphries
Roger, I don't believe that patch will change behavior. See my last message: the fields appear to be unexported according to reflection. That patch has the encoding/json package checking StructField.PkgPath, which should be blank for exported fields. For these fields, it is "go.builtin", which

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread dc0d
1 - The case clause clearly represents a send action. 2 - So there must be a channel to send to, and f1() must return a channel. 3 - If that channel (returned by f1()) is nil, then the clause must get ignored. 4 - If the returned channel (returned by f1()) is not nil, then f2() will be executed.

Re: [go-nuts] Re: How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 5:02 PM Christian LeMoussel wrote: > Is it correct /best way ? Hopefully/only. But as noted previously, not tested. > There is no memory leaks ? Something must eventually C.free() the memory allocated by C.CString(). -- -j -- You received this

[go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread dc0d
Can anybody help me understand the reason? (It's in the spec. That's not the reason) On Sunday, December 31, 2017 at 10:14:31 AM UTC+3:30, dc0d wrote: > > Assume there is this select statement: > > for { > select { > // ... > // ... > > case rcvd <- first(): > } > } > > > The

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread dc0d
In the sample you have provided, a send syntax is used. And considering that, (IMHO) f1() must be evaluated first. On Tuesday, January 23, 2018 at 6:13:08 PM UTC+3:30, Ian Lance Taylor wrote: > > On Tue, Jan 23, 2018 at 5:44 AM, dc0d > wrote: > > > > Can anybody help

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 4:45 PM dc0d wrote: > In the sample you have provided, a send syntax is used. And considering that, (IMHO) f1() must be evaluated first. Consider f1() is a dispatcher. If it is to be evaluated first then it may create and return a new channel

[go-nuts] Re: How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Christian LeMoussel
I do this devidx := C.scan_bus((*C.char)(unsafe.Pointer([0])), C.int(cap(sbuf)), C.CString(sn), C.CString(product)) Is it correct /best way ? There is no memory leaks ? . -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Gorilla Sessions Example Question

2018-01-23 Thread aikiav8r
I was working with the Gorilla sessions example https://gowebexamples.com/sessions/, and I am having a problem with the "logout". I created the given file, and ran it. the initial attempt to access /secret correctly resulted in the "Forbidden" response, and after a /login, the /secret also

Re: [go-nuts] Unused code warnings

2018-01-23 Thread Paul Jolly
Take a look at unused: https://github.com/dominikh/go-tools That will help you to eliminate unused code pre compile time. On 23 Jan 2018 13:38, "Patrik Iselind" wrote: > Hi guys, > > Is there a way to get `go install` to error out if there is unused > functions in the

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread Ian Lance Taylor
On Tue, Jan 23, 2018 at 5:44 AM, dc0d wrote: > > Can anybody help me understand the reason? (It's in the spec. That's not the > reason) It gives a precise order of evaluation of the select statement. Consider case f1() <- f2(): It's useful to specify the order in

Re: [go-nuts] Re: JSON and Embedded Types (Aliases)

2018-01-23 Thread dc0d
Exactly. That's why I asked before why we are allowed to embed type aliases. It should be either not possible, or be properly handled by the type system (and tools). On Tuesday, January 23, 2018 at 6:02:54 PM UTC+3:30, Josh Humphries wrote: > > Roger, > I don't believe that patch will change

[go-nuts] Best batch processing example in go

2018-01-23 Thread Peng Yu
Hi, I'd like to implement batch processing in go. There should be a goroutine for reading input and several worker goroutines for processing the input in chunks. The workers may not finish processing the chunks in the same order as they are in the input. But the processing results should be

Re: [go-nuts] How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Jan Mercl
On Tue, Jan 23, 2018 at 4:54 PM Christian LeMoussel wrote: > devidx := C.scan_bus((*C.char([0])), C.int(cap(sbuf)), C.CString(sn), C.CString(product)) Not tested: devidx := C.scan_bus((*C.char)(unsafe.Pointer([0])), C.int(cap(sbuf)), C.CString(sn), C.CString(product)) --

[go-nuts] How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-23 Thread Christian LeMoussel
I have a this C function int scan_bus(char *sbuf, int sbuflen, char* sn, char* ps) I'm trying to call this that takes several char * byte buffers as arguments. In Go, I have sbuf in []byte slices. But I can't figure out how to pass these into the C function. I've tried var (

[go-nuts] Re: Gorilla Sessions Example Question

2018-01-23 Thread matthewjuran
Since store.Get may silently make a new session I would first verify the session key gotten in the logout handler matches what you sent in the cookie. Maybe try -i on the logout curl call? Matt On Tuesday, January 23, 2018 at 8:51:40 AM UTC-6, aiki...@gmail.com wrote: > > I was working with

[go-nuts] Re: Best batch processing example in go

2018-01-23 Thread matthewjuran
I don’t have an example but a concurrent solution seems straightforward to reason about. Here’s a description of where I’d start: Perhaps have a type to send on the buffered chan from the one producer goroutine? type Chunk struct { Index int Data []byte } Then make any number of worker