[go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-22 Thread mountainfpf
exec code: package main import "fmt" func main() { fmt.Println(F() == F()) } func F() func() int { i := 0 return func() int { i++ return i } } i got : # command-line-arguments ./key.go:6:18: invalid operation: F() == F() (func can only be compared to nil)

[go-nuts] About how to study chan send and receive data

2019-01-22 Thread mountainfpf
file:main.go code : package main func main() { a := make(chan int) go func() { a <- 1 }() println(<-a) } go build -o main main.go gdb main make(chan int) really exec: func makechan(t *chantype, size int) *hchan { elem := t.elem ... ... } go func() really exec

Re: [go-nuts] Interpretting the pprof memory profile

2019-01-22 Thread Patrik Iselind
Den tisdag 22 januari 2019 kl. 22:14:20 UTC+1 skrev Ian Lance Taylor: > > On Tue, Jan 22, 2019 at 11:21 AM Patrik Iselind > wrote: > > > > I'm looking at memory profiles and have a hard time interpreting what I > see. I'm trying to better understand what I am looking at in `go tools > pprof`

Re: [go-nuts] "All types implement the empty interface"

2019-01-22 Thread Francisco Dalla Rosa Soares
First of all let's not confuse Go's Interfaces with Java's class inheritance. Read again the definition from the link you sent: "An interface type specifies a method set called its interface. A variable of interface type can store a value of any type with a method set that is any superset of

[go-nuts] serverless frameworks

2019-01-22 Thread Sankar
Hi Now that Google has released support for Cloud Functions, I am curios to know are there any frameworks that the community is already using for standardizing the serverless deployments. A few things that I would be happy to have are: 1) Single command deploy of multiple functions based on

[go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Andrei Avram
If it's about a method you've defined on a pointer and you want to call it on the value: https://play.golang.org/p/zMVivcaXrf3 -- 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,

Re: [go-nuts] "All types implement the empty interface"

2019-01-22 Thread Jan Mercl
On Wed, Jan 23, 2019 at 6:27 AM 伊藤和也 wrote: > So an empty interface also implements an empty interface? Interfaces do not implement anything. Instances of non-interfaces types do. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] "All types implement the empty interface"

2019-01-22 Thread 伊藤和也
I found the explanation "All types implement the empty interface". https://golang.org/ref/spec#Interface_types So an empty interface also implements an empty interface? and again the empty interface implements an empty interface and the empty inter... What I imagine is like this below.

Re: [go-nuts] why map the key type must not be a function, map, or slice

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 7:59 PM wrote: > > When i use the func, map slice as the key of map, it isn't work! > So I lookup source why, i find You don't have to look at the source, you can look at the language spec. https://golang.org/ref/spec#Map_types "The comparison operators ==

[go-nuts] why map the key type must not be a function, map, or slice

2019-01-22 Thread mountainfpf
When i use the func, map slice as the key of map, it isn't work! So I lookup source why, i find // spec: "The comparison operators == and != must be fully defined // for operands of the key type; thus the key type must not be a // function, map, or slice."

[go-nuts] Re: Writing an Excel add-in using Go?

2019-01-22 Thread Kevin Powick
Your scope is not entirely defined in the exchanges I've read so far, so I don't know if the following has merit, but have you considered using Excel's built in VBA and the Excel.XmlHttpRequest object to make HTTP based requests to a service written in Go? There are several advantages,

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-22 Thread 'simon place' via golang-nuts
thanks again. FWIW seems to me this might have some interesting effects, otherwise unobtainable, given the different 'clones' still all implement the same interface. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: How concatenate more type of formatting for the same variable (fmt.Printf)

2019-01-22 Thread Michael Jones
Antonio, The first example has three format verbs and just two values. That is usually wrong. Use "go vet" to be warned of such errors. Sam's answer explains how you can print two values three ways using indexing "[1]" and "[2]". Your new example has two format verbs and two values. This is

Re: [go-nuts] Re: do you use binary-only packages?

2019-01-22 Thread Ian Denhardt
I feel like I should stress this a bit more, because it's really important: It is under no circumstances reasonable to rely on lack of source code for security. History has taught us time and time again that security through obscurity doesn't work, and home grown/custom algorithms are usually

[go-nuts] Re: Why not a mixture of value and pointer receiver?

2019-01-22 Thread T L
https://groups.google.com/forum/#!topic/golang-nuts/gJtXQhpoA4U On Tuesday, January 22, 2019 at 5:59:51 PM UTC-4, Xinhu Liu wrote: > > In "A Tour of Go " I read: > > In general, all methods on a given type should have either value or >> pointer receivers, but

[go-nuts] Re: impl of Elem() in value.go

2019-01-22 Thread T L
In runtime internal, blank and non-blank interface types are represented with different structures. https://go101.org/article/value-part.html#interface-structure mentions this a little. On Tuesday, January 22, 2019 at 1:38:23 PM UTC-4, 徐建海 wrote: > > when i dig ingo value.go, i found that: >

[go-nuts] Re: Why not a mixture of value and pointer receiver?

2019-01-22 Thread 伊藤和也
Yes I agree with you. It's confusing and so hard to understand. 2019年1月23日水曜日 6時59分51秒 UTC+9 Xinhu Liu: > > In "A Tour of Go " I read: > > In general, all methods on a given type should have either value or >> pointer receivers, but not a mixture of both. > >

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 1:59 PM Xinhu Liu wrote: > > In "A Tour of Go" I read: > >> In general, all methods on a given type should have either value or pointer >> receivers, but not a mixture of both. > > > But why not? > > Methods having value receiver can be called by both value type and

[go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Xinhu Liu
In "A Tour of Go " I read: In general, all methods on a given type should have either value or pointer > receivers, but not a mixture of both. But why not? Methods having value receiver can be called by both value type and pointer type. The same is for

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 7:55 AM 'simon place' via golang-nuts wrote: > > thanks for the info, answered my OP, but raised some more questions... > > presumably the go runtime is compiled with gccgo? so would that mean there > are possibly cloned functions in it? When using gccgo, yes, and yes.

Re: [go-nuts] Re: do you use binary-only packages?

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 1:06 PM Wei Tang wrote: > > Well, I do think Binary-only packages are very important for some security > case, such as authentication algorithm in a private enterprise。 I would not recommend using them in that way. A binary package should be thought of as a slightly

Re: [go-nuts] Interpretting the pprof memory profile

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 11:21 AM Patrik Iselind wrote: > > I'm looking at memory profiles and have a hard time interpreting what I see. > I'm trying to better understand what I am looking at in `go tools pprof` why > looking at the raw data. All 'groups' at the end of output from >

[go-nuts] Re: do you use binary-only packages?

2019-01-22 Thread Wei Tang
Well, I do think Binary-only packages are very important for some security case, such as authentication algorithm in a private enterprise。 在 2018年10月19日星期五 UTC+8上午1:16:43,Russ Cox写道: > > The go command supports "binary-only packages", in which > the compiled .a file is installed in GOROOT/pkg

Re: [go-nuts] This Makes No Sense

2019-01-22 Thread Michael Jones
uh oh. ;-) On Tue, Jan 22, 2019 at 12:14 PM Bakul Shah wrote: > This is kind of like tic-tac-toe! The first player has an advantage. > Gomoku's swap2 rule makes it fairer and more interesting! > > Also a good game to practice writing alpha-beta pruning search (for > playing with a computer)! >

Re: [go-nuts] This Makes No Sense

2019-01-22 Thread Bakul Shah
This is kind of like tic-tac-toe! The first player has an advantage. Gomoku's swap2 rule makes it fairer and more interesting! Also a good game to practice writing alpha-beta pruning search (for playing with a computer)! Representing the board as two sets of n^2 bitmaps would speed things up

Re: [go-nuts] Re: This Makes No Sense

2019-01-22 Thread Michael Jones
I could not decode the question, so I just wrote a program to do it all. John, does this help? Change the constants for whatever board geometry and n-in-a-row victory rule you want. https://play.golang.org/p/JtouiOlkGCO P.S. the progression from 3 to 4 to 5 in a row is a great way to teach kids

[go-nuts] Interpretting the pprof memory profile

2019-01-22 Thread Patrik Iselind
Hi, I'm looking at memory profiles and have a hard time interpreting what I see. I'm trying to better understand what I am looking at in `go tools pprof` why looking at the raw data. All 'groups' at the end of output from /debug/pprof/heap have lines that begin with "0: 0 [0: 0] @0x...".

[go-nuts] Build with C dependencies

2019-01-22 Thread Luke Mauldin
I have a Go program that I need to link against multiple C libraries in order to compile. I am setting the CFLAGS and LDFLAGS through #cgo directives which works nicely. My problem is that I would like to run my go builds (and test, etc...) inside a docker container so I can put the C

[go-nuts] impl of Elem() in value.go

2019-01-22 Thread 徐建海
when i dig ingo value.go, i found that: func (v Value) Elem() Value { k := v.kind() switch k { case Interface: var eface interface{} if v.typ.NumMethod() == 0 { eface = *(*interface{})(v.ptr) } else { eface = (interface{})(*(*interface { M() })(v.ptr)) } x := unpackEface(eface) if x.flag != 0 {

Re: [go-nuts] Re: How to end producer from the consumer side

2019-01-22 Thread Jon Betti
I'd also tend toward passing in a context to the producer rather than returning a "kill" channel. That way you get correct cancellation when you begin to string together multiple producers. I'd recommend reading https://blog.golang.org/pipelines in any case. https://play.golang.org/p/ftgqSokde1c

Re: [go-nuts] Re: How to end producer from the consumer side

2019-01-22 Thread Josh Humphries
On Tue, Jan 22, 2019 at 8:33 AM wrote: > Hi, we have the same problem of OP. > But, in the Chris's playground there could be an error, indeed if the > consumer > runs slower of the producer the program ends in a deadlock. > > To force this behavior just add a time.Sleep() after the foor loop in

Re: [go-nuts] Golang net/http server returning empty packets

2019-01-22 Thread robert engels
Sounds a lot like a concurrency issue - possibly not flushing the request, or the request is being processed / timing out from another go routine. I would start by adding some lifecycle request traces and processing these in an automated fashion - almost the only way to debug highly concurrent

Re: [go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread robert engels
Depending on the nature of the plugin, it can be a much easier setup, and far more resilient. Different Excel versions get very flaky, the lifecycle of plugins can be difficult with lots of external state. By putting it is a different process it can be easier to debug, far more resilient, and

[go-nuts] Golang net/http server returning empty packets

2019-01-22 Thread Tom Cook
I have a moderately complex HTTP server written using net/http HandlerFuncs. Testing one request at a time all is well, but when I start putting significant load on it, it sometimes returns empty packets, ie no HTTP response headers, no status code, nothing. The clients are all written using

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-22 Thread 'simon place' via golang-nuts
thanks for the info, answered my OP, but raised some more questions... presumably the go runtime is compiled with gccgo? so would that mean there are possibly cloned functions in it? and i can see that gcc can clone for know value (constant) parameters, but can't see any other techniques,

Re: [go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread mrecht . m
Thanks! That's what I thought/feared.. On Tuesday, January 22, 2019 at 4:47:33 PM UTC+1, robert engels wrote: > > But it also depends on what you me by add-in - if it is just processing > Excel files, that’s one thing - if its a live data source I think the best > way is a network bridge -

Re: [go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread mrecht . m
Nothing as such.. What I would like to write, though. Is a Excel add-in having a ribbon and UDFs. And I am not sure how or if this is possible using COM from Go. On Tuesday, January 22, 2019 at 4:46:14 PM UTC+1, robert engels wrote: > > What is wrong with using COM from Go ? > > On Jan 22,

Re: [go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread robert engels
But it also depends on what you me by add-in - if it is just processing Excel files, that’s one thing - if its a live data source I think the best way is a network bridge - that’s what we’ve used - a thin COM layer that Excel uses communicates with the process via TCP. > On Jan 22, 2019, at

Re: [go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread robert engels
What is wrong with using COM from Go ? > On Jan 22, 2019, at 9:35 AM, mrech...@gmail.com wrote: > > Hi, > > I was wondering if there is a library supporting writing an Excel add-in in > Go. Googling did not brought anything besides the Window COM support library. > Therefore, the only way I

[go-nuts] Re: This Makes No Sense

2019-01-22 Thread Marcus Low
I meant "constant *space* overhead", sorry. On Tuesday, January 22, 2019 at 11:38:02 PM UTC+8, Marcus Low wrote: > > As Justin Israel said, you can probably scan them to int and test them as > ints. > > However, if you *really* need them to be parsed as string, this will help > your runtime, at

[go-nuts] Re: This Makes No Sense

2019-01-22 Thread Marcus Low
As Justin Israel said, you can probably scan them to int and test them as ints. However, if you *really* need them to be parsed as string, this will help your runtime, at the cost of constant overhead: var ( valueSet = map[string]struct{}{ "1":nil, "2":nil, "3":nil,

[go-nuts] Writing an Excel add-in using Go?

2019-01-22 Thread mrecht . m
Hi, I was wondering if there is a library supporting writing an Excel add-in in Go. Googling did not brought anything besides the Window COM support library. Therefore, the only way I could think of so far is writing a back-end service in Go and communicating with it using 0MQ/Nanomsg/... from

Re: [go-nuts] Using "er" and "able" for interfaces

2019-01-22 Thread Victor Giordano
Ouch, i guess that the english grammar is not happy with that comment. Commander :D. let's agree that naming is important, you guys also say so too. This post is, after all is about naming, so let's try to not criquite the grammar as it one the

[go-nuts] Re: How to end producer from the consumer side

2019-01-22 Thread fabiuzz91
Hi, we have the same problem of OP. But, in the Chris's playground there could be an error, indeed if the consumer runs slower of the producer the program ends in a deadlock. To force this behavior just add a time.Sleep() after the foor loop in main. --> https://play.golang.org/p/A3i6TEyGQm_L

Re: [go-nuts] Re: What does "nil implay?

2019-01-22 Thread Jan Mercl
On Tue, Jan 22, 2019 at 2:17 PM Victor Giordano wrote: > From a language specific level (higher abstraction) is means undefined, is the absence of a value. No value in Go can _not_ have a value. > Something whose value is nil/null/undefined is not defined. All nil values are perfectly

[go-nuts] Re: How concatenate more type of formatting for the same variable (fmt.Printf)

2019-01-22 Thread Antonio Romeo Riga
Don't work, print 2 time the same variable (coin). The solution is : fmt.Printf("%-15.2f %5.2f\n", coin, piggybank) Now add spaces and format the float variable coin (-15v + 5.2f) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: What does "nil implay?

2019-01-22 Thread Victor Giordano
i just make an anwser. El lunes, 21 de enero de 2019, 19:21:29 (UTC-3), Ian Lance Taylor escribió: > > On Mon, Jan 21, 2019 at 5:19 AM 伊藤和也 > > wrote: > > > > So what do you think "nil" represents instead? > > "nil" is just a special value? for slices, maps. > > There is no one

[go-nuts] Re: What does "nil implay?

2019-01-22 Thread Victor Giordano
As i see things... - From a language specific level (*higher abstraction*) is means *undefined, is the absence of a value. Something whose value is nil/null/undefined is not defined.* - *On a lower level of abstraction it may be tweeking a little bit for having an