Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread 'Axel Wagner' via golang-nuts
Which would imply that something like this type ( Foo int Foo int ) might be legal. I don't understand (and thusly disagree) why that would be in any sense "less confusing". On Mon, Oct 3, 2016 at 7:26 AM, T L wrote: > > > On Monday, October 3, 2016 at 1:52:10 AM UTC+8, Marvin Renich wro

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread T L
On Monday, October 3, 2016 at 1:52:10 AM UTC+8, Marvin Renich wrote: > > * Matt Harden > [161001 23:34]: > > I do think that T L has a point. The spec defines the syntax of the > > language, and TypeSpec refers to a syntactical construct. It is not > > possible in the syntax of the language to

[go-nuts] How to initialize all members of a slice

2016-10-02 Thread Sarah Ahmed
Hello, I am trying to initialize the "State" to a default value "NY" of Address slice. The following code only sets the first element's State. I do not know how many element would be in my input. Is there any easy way to do it? Thanks in advance for your help. package main import ( "encoding/js

[go-nuts] Overflow behavior guarantees for atomic.Add*

2016-10-02 Thread Nicholas Knight
I'm familiar with (and greatly appreciate!) the guarantees regarding overflow for ordinary integer arithmetic in the Go spec, but I've been unable to locate anything that reassures me that similar guarantees apply for the sync/atomic.Add* functions. Is there any official statement anywhere on

[go-nuts] Re: about interface data pointer

2016-10-02 Thread Dave Cheney
-gcflags="-m -m" will make the compiler print out its escape analysis choices. This might be easier than instrumenting your code, which might affect the escape analysis decisions. On Monday, 3 October 2016 13:48:47 UTC+11, 刘桂祥 wrote: > > Yes you are right . thanks a lot and I try more debug i

[go-nuts] Re: about interface data pointer

2016-10-02 Thread 刘桂祥
Yes you are right . thanks a lot and I try more debug info and have looked that: func main() { println("debug") a := interface{}(100) println(&a, a) b := fmt.Sprint(a) println("debug1", b, &b, Pointer(*((*uintptr)(Pointer(&b, *((*int)( Pointer(uintptr(Pointer(&b)) + 8)

[go-nuts] Re: about interface data pointer

2016-10-02 Thread Dave Cheney
On Monday, 3 October 2016 12:39:34 UTC+11, 刘桂祥 wrote: > package main > > > import ( >     "fmt" > ) > func main() { >     a := interface{}(100) >     println(&a, a) >     fmt.Sprint(a) > } > > > go run x.go  the output: > > > 0xc42003bf18 (0x89040,0xc42000a2c0) > > > > I just want to ask 

[go-nuts] about interface data pointer

2016-10-02 Thread 刘桂祥
package main import ( "fmt" ) func main() { a := interface{}(100) println(&a, a) fmt.Sprint(a) } go run x.go the output: 0xc42003bf18 (0x89040,0xc42000a2c0) I just want to ask 0xc42000a2c0 as the a (interface{}) 's data pointer is point to where ? heap ? also I test this: fu

[go-nuts] Re: Any plan on improving Go's escape analysis?

2016-10-02 Thread 'David Chase' via golang-nuts
One thing to know about Go's escape analysis is that it works bottom up, package by package, so it does use interprocedural information. Right now that information is pretty coarse, on the level of "escapes", "content escapes", and "[content] transmitted to result N". For a parameter with interf

[go-nuts] Re: Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-02 Thread Caleb Doxsey
One thing you can try is to increase the number of locks so that the goroutines aren't all stopped on a single lock. For example you can partition your stores: https://play.golang.org/p/y16yr57KcQ type PartitionedStore struct { stores []Store } func NewPartitionedStore(sz int) *PartitionedStore

Re: [go-nuts] slice: copy to zero length slice

2016-10-02 Thread Pietro Gagliardi
No, it should not operate that way. Remember that all function calls in Go pass arguments by value. A slice is actually a value somewhat analogous to type SliceOfT struct { Data*T Len int Cap int } When

Re: [go-nuts] calling go functions from c

2016-10-02 Thread webuser1200
> > There is some overhead when using gccgo, because of the need to > interact with the Go scheduler. The overhead should be slightly less. > Any idea what (very rough is fine) that overhead is when compared to the standard go toolchain? -- You received this message because you are sub

Re: [go-nuts] Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-02 Thread Matt Harden
Re: transactional memory, in Intel this is called TSX-NI. It looks like even for the latest generation (Skylake), it's enabled for certain processors and disabled for others: compare all skylake processors

Re: [go-nuts] Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-02 Thread Jesper Louis Andersen
> > > This program has a store that holds the data, and a sync.Mutex that guards > concurrent access on reads and writes. This is a snippet of the locking > based implementation: > > type Store struct { >durations map[string]*Distribution >counters map[string]int64 >samples map[strin

Re: [go-nuts] Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-02 Thread Justin Israel
Do you get better performance when you remove the defer and do an explicit unlock at the end of the function? There are a new references to the defer process happening in your profile. I'm guessing the try/finally in Java is cheaper. On Mon, 3 Oct 2016, 3:17 AM wrote: > Hi, > > I've written a sm

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread Marvin Renich
* Matt Harden [161001 23:34]: > I do think that T L has a point. The spec defines the syntax of the > language, and TypeSpec refers to a syntactical construct. It is not > possible in the syntax of the language to create two named types that > originate in the same TypeSpec. We seem to be saying t

[go-nuts] [ANN] gopherpit - service to manage remote import paths with custom domains

2016-10-02 Thread Janoš Guljaš
Hello, A few months ago, I announced [0] a service for managing Go import paths for custom domains gopherpit.com. It was made for personal needs for private and commercial projects that are not hosted on github. The source code and binary releases are now available on GitHub [1], as well as doc

[go-nuts] Re: slice: copy to zero length slice

2016-10-02 Thread djadala
Hi, you want to use append, not copy: https://play.golang.org/p/1TXCsC4-GJ On Sunday, October 2, 2016 at 5:18:42 PM UTC+3, 高橋誠二 wrote: > > As official doc explains, copy to zero length slice results to be empty. > > package main > > import "fmt" > > func main() { > src := []int{1, 2, 3} >

[go-nuts] SWIG and anonymous field inheritance

2016-10-02 Thread Shengqiu Li
Hi all, I'm making a binding of a C++ library for go, and I'm wondering why the anonymous field inheritance isn't used in the go wrapper code. I have found a piece of comment in the go backend of SWIG, saying: // For each method defined in a base class but not defined in > // this c

[go-nuts] slice: copy to zero length slice

2016-10-02 Thread 高橋誠二
As official doc explains, copy to zero length slice results to be empty. package main import "fmt" func main() { src := []int{1, 2, 3} dst := []int{} fmt.Println(len(dst)) copy(dst, src) fmt.Println(src) fmt.Println(dst) // [1 2 3] // [] src2 := []int{1, 2, 3

[go-nuts] Go locking and channels much slower than Java equivalent, program spends most of time in sync.(*Mutex).Lock() and sync.(*Mutex).Unlock()

2016-10-02 Thread toefel18
Hi, I've written a small library (https://github.com/toefel18/go-patan) in that stores counters and collects statistics (running min/max/average/stddeviation) of a program during runtime. There is a lock based implementation and a channel based implementation. I've written this library before

[go-nuts] Re: OpenWRT-friendly golang hardware

2016-10-02 Thread Conor O'Neill
I have run Go 1.4 webapps on the original Onion Omega which uses OpenWRT. I used an unofficial port that someone else did to MIPS32. Details here: http://conoroneill.net/three-ways-to-build-go-14-binaries-for-mips32-onion-omega-golang/ 16MB of flash is always going to be a challenge tho. On

Re: [go-nuts] OpenWRT-friendly golang hardware

2016-10-02 Thread Simon Larcher
>From what I understood, MIPS32 support for Golang has been in the pipeline for some time already so it might appear at some point. MIPS64 is there since 1.6 and fully supported in 1.7. Sadly, very few OpenWRT hardware uses MIPS64, only the higher grade products do. You will have to use gccgo anyw

Re: [go-nuts] Initialize Fields

2016-10-02 Thread dc0d
You are right. But this felt clean and obvious syntax. Back to NewGate! On Sunday, October 2, 2016 at 1:47:27 PM UTC+3:30, Axel Wagner wrote: > > Because that wouldn't be "the zero value" anymore. > It would require that, when you do e.g. > x := make([]gate, 4096) > that the compiler emits the cod

Re: [go-nuts] Any plan on improving Go's escape analysis?

2016-10-02 Thread Jesper Louis Andersen
On Sat, Oct 1, 2016 at 6:45 PM, Ian Lance Taylor wrote: > There are improvements to the compiler's escape analysis in every release. Also, escape/representation analysis is approximate in nature. So you can't easily detect all variants of this and have the compiler optimize them. A compiler ten

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread T L
Thanks for the explanation. I would admit, my interpretation of some English words and definitions may be wrong. The main reason would be my English is not good, and maybe also some culture reasons here. Thank all also for the patience! On Sunday, October 2, 2016 at 5:14:40 PM UTC+8, Axel Wagn

Re: [go-nuts] Initialize Fields

2016-10-02 Thread 'Axel Wagner' via golang-nuts
Because that wouldn't be "the zero value" anymore. It would require that, when you do e.g. x := make([]gate, 4096) that the compiler emits the code to initialize everything. The same recursively for each type that contains a gate and for each function which uses a local gate variable. So this would

[go-nuts] Re: vender folder problem

2016-10-02 Thread topiyadharesh
Got It. Vendor folder should be at root of repo. thanks. On Sunday, 2 October 2016 09:37:06 UTC+5:30, topiya...@gmail.com wrote: > > I have two import packages and have it in vendor dir. > > kitprometheus "github.com/go-kit/kit/metrics/prometheus" > > stdprometheus "github.com/prometheus/client_go

[go-nuts] Initialize Fields

2016-10-02 Thread dc0d
Why there is no field initializer in Go? Like: type gate struct { outgoing = make(chan *sendRequest) incoming = make(chan update, 10) } Doesn't that make zero value more useful? The syntax already exists for global variables so IMHO not much new would get introduced to the language synt

Re: [go-nuts] Re: vender folder problem

2016-10-02 Thread topiyadharesh
my main.go is in https://github.com/dharesh007/challenge2016/tree/master/cmd/locationService folder and vender dir is in it. where should I put vendor dir. On Sunday, 2 October 2016 14:47:53 UTC+5:30, Axel Wagner wrote: > > That repository contains no vendor/ folder. > > On Sun, Oct 2, 2016 at 9

Re: [go-nuts] Re: vender folder problem

2016-10-02 Thread 'Axel Wagner' via golang-nuts
That repository contains no vendor/ folder. On Sun, Oct 2, 2016 at 9:49 AM, wrote: > I am using vendor version only > > On Sunday, 2 October 2016 12:40:28 UTC+5:30, Axel Wagner wrote: >> >> You seemingly use both a vendored version of go-kit and a non-vendored >> version (likely you are importin

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread 'Axel Wagner' via golang-nuts
On Sun, Oct 2, 2016 at 10:07 AM, T L wrote: > Ok, in fact, this is really a problem about how to comprehend the words in > go spec. > > There are two different interpretations of the words for the following > two questions, > 1. what does "the same type-spec" mean? > 2. what does "two named types

[go-nuts] Any plan on improving Go's escape analysis?

2016-10-02 Thread Aliaksandr Valialkin
fmt.* functions may call Stringer and Formatter interface methods for the passed arguments, so the arguments may escape when calling these methods. Probably, conditional escaping may be implemented for function argument. For example of fmt.*, escape only arguments implementing Stringer or Format

Re: [go-nuts] Re: go escape analysis

2016-10-02 Thread 刘桂祥
Hi Chris: I am gopher from Beijing China . I am very like programing and adore the old hack culture . and NBA too! I am very happy in google groups and receive the answer so quickly. go on practice programing and improve my badly english ques

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread T L
Ok, in fact, this is really a problem about how to comprehend the words in go spec. There are two different interpretations of the words for the following two questions, 1. what does "the same type-spec" mean? 2. what does "two named types" mean? Your interpretations: 1. "the same type-spec" <

Re: [go-nuts] Re: vender folder problem

2016-10-02 Thread topiyadharesh
I am using vendor version only On Sunday, 2 October 2016 12:40:28 UTC+5:30, Axel Wagner wrote: > > You seemingly use both a vendored version of go-kit and a non-vendored > version (likely you are importing something from outside of vendor/ which > imports go-kit itself) and are trying to use a C

[go-nuts] Re: vender folder problem

2016-10-02 Thread topiyadharesh
https://github.com/dharesh007/challenge2016 I think it's related to package alias. "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" works fine. but kitprometheus "github.com/go-kit/kit/metrics/prometheus" stdprometheus "github.com/prometheus/client_golang/pr

Re: [go-nuts] Re: vender folder problem

2016-10-02 Thread 'Axel Wagner' via golang-nuts
You seemingly use both a vendored version of go-kit and a non-vendored version (likely you are importing something from outside of vendor/ which imports go-kit itself) and are trying to use a Counter from the vendored version in the unvendored version. As the two are different packages, the Counter

Re: [go-nuts] How to define two identical named types?

2016-10-02 Thread 'Axel Wagner' via golang-nuts
So, I don't really get what's the problem here, tbh. The spec seams perfectly fine as it is right now to me. * If two named types come from different type-specs, they are not treated as identical. We covered how that can happen. * If two named types come from the same type-spec, then they are iden