Re: [go-nuts] Help: how to add `this` feature to my go source?

2016-10-01 Thread Wang Yarco
Yes, maybe...But maybe after several days (months), i want other features added those are not suitable for code generation. ...So change it little by little would make me feel happy (Aha! i could customize it!), not do a separate generation tool that i would totally forget after several days.

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 10:54 T L wrote: > > > Then how are they defined? > Discussed earlier in this thread: they are predeclared. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

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

2016-10-01 Thread T L
In Go spec, https://golang.org/ref/spec#Type_identity, it says: Two named types are identical if their type names originate in the same TypeSpec . But, in my impression, in Golang, there are only two pair types

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 3:31:00 PM UTC+8, Jan Mercl wrote: > > > > On Sat, Oct 1, 2016, 09:13 T L wrote: > >> In Go spec, https://golang.org/ref/spec#Type_identity, it says: >> >> Two named types are identical if >> their type

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

2016-10-01 Thread bronze man
When I call `fmt.Println(1,2) `, I expect all the interfaces of the arguments should alloc on stack so that the garbage collection part will use less cpu time, but currently it is alloc on heap.Because I found that I do not need that alloced valuable (interface{})(1) is not used after this

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 9:48 AM T L wrote: > If no two custom named types are identical, why spec says that? Because identical named types do exists. You have already listed them. -- -j -- You received this message because you are subscribed to the Google Groups

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 3:47:09 PM UTC+8, bronze man wrote: > > When I call `fmt.Println(1,2) `, I expect all the interfaces of the > arguments should alloc on stack so that the garbage collection part will > use less cpu time, but currently it is alloc on heap.Because I found that I

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 4:02:14 PM UTC+8, Jan Mercl wrote: > > On Sat, Oct 1, 2016 at 9:48 AM T L > wrote: > > > If no two custom named types are identical, why spec says that? > > Because identical named types do exists. You have already listed them. > > -- > > -j

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 4:34:08 PM UTC+8, Jan Mercl wrote: > > > > On Sat, Oct 1, 2016, 10:25 T L wrote: > >> >> >> On Saturday, October 1, 2016 at 4:02:14 PM UTC+8, Jan Mercl wrote: >> >>> On Sat, Oct 1, 2016 at 9:48 AM T L wrote: >>> >>> > If no

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 11:27 AM T L wrote: > If they are predeclared, then is it meaningless to say their type names originate in the same TypeSpec? I don't know why do you think it's meaningless. byte and uint8 share the same

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 10:25 T L wrote: > > > On Saturday, October 1, 2016 at 4:02:14 PM UTC+8, Jan Mercl wrote: > > On Sat, Oct 1, 2016 at 9:48 AM T L wrote: > > > If no two custom named types are identical, why spec says that? > > Because identical named

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 5:00:53 PM UTC+8, Jan Mercl wrote: > > > > On Sat, Oct 1, 2016, 10:54 T L wrote: > >> >> >> Then how are they defined? >> > > Discussed earlier in this thread: they are predeclared. > > -- > > -j > If they are predeclared, then is it

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 09:13 T L wrote: > In Go spec, https://golang.org/ref/spec#Type_identity, it says: > > Two named types are identical if > their type names originate in the same TypeSpec >

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 12:47 AM, bronze man wrote: > When I call `fmt.Println(1,2) `, I expect all the interfaces of the > arguments should alloc on stack so that the garbage collection part will use > less cpu time, but currently it is alloc on heap.Because I found that I

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 5:23 AM, web user wrote: > On a side not. The functions I call will from c into go will be called very > frequently and the overhead of a callback from c might become an issue. I've > heard that overhead can be as high as 200ns. Couple of questions: >

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 5:17 AM, wrote: > > - I used the int and char C. directly in fmt.printf and it seemed to > work. Is that ok to do without having to convert into a native go type? Yes. > - What about c types like > > C short -> ? > C __int64 -> ? > > What file are

Re: [go-nuts] Cast from int to uint64 performance cost

2016-10-01 Thread Agniva De Sarker
Thanks ! Appreciate the help. :) On Saturday, 1 October 2016 22:16:10 UTC+5:30, Ian Lance Taylor wrote: > > On Sat, Oct 1, 2016 at 12:24 AM, > wrote: > > > > I am using a variable to track the no. of bytes written to a file so > far. > > Now the fmt.Fprint command

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

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 12:38:00 AM UTC+8, Ian Lance Taylor wrote: > > On Sat, Oct 1, 2016 at 8:55 AM, T L > wrote: > > > > On Saturday, October 1, 2016 at 11:29:35 PM UTC+8, Axel Wagner wrote: > >> > >> It *is* possible to define two named types with the same

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

2016-10-01 Thread webuser1200
Thanks for putting this together. I was trying to figure out how to do callback from c to go. There are fewer examples on the web for that since most of them deal with calling c code from go. C int -> go C.int C unsigned char -> C.uchar C char -> C.char C unsigned int -> C.uint C double ->

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

2016-10-01 Thread Jan Mercl
> but we even don't know how the builtin byte and uint8 are defined? Yes we know, see: https://golang.org/ref/spec#Numeric_types > How do you know their type names originate in the same TypeSpec? Because that's how the semantics of predeclared

[go-nuts] OpenWRT-friendly golang hardware

2016-10-01 Thread Aldrin Leal
Just wondering: Which OpenWRT-based hardware you'd pick? My idea would be to write a few middleware code for an existing router platform. Most OpenWRT are based on MIPS SoCs, so this is a problem and ARM would be preferred. Plus, space is a concern as well Any ideas? Thank you -- -- Aldrin

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

2016-10-01 Thread web user
On a side not. The functions I call will from c into go will be called very frequently and the overhead of a callback from c might become an issue. I've heard that overhead can be as high as 200ns. Couple of questions: 1. Is the overhead not there when using gccgo? 2. What is the current state of

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 6:09:52 PM UTC+8, Jan Mercl wrote: > > > On Sat, Oct 1, 2016 at 12:03 PM T L > wrote: > > > I don't think it is meaningless byte and uint8 share the same type spec. > > Great. > > > I just think the text "Two named types >

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

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 2:37:23 AM UTC+8, Jan Mercl wrote: > > > On Sat, Oct 1, 2016 at 7:56 PM T L > wrote: > > > Then could you provide an example two identical custom named types > originate in the same TypeSpec? > > Answer is in the first response to the OP. > I

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

2016-10-01 Thread T L
I filed an issue here: https://github.com/golang/go/issues/17310 but griesemer closed it. Waiting for griesemer to make more explanation here. On Saturday, October 1, 2016 at 11:29:35 PM UTC+8, Axel Wagner wrote: > > It *is* possible

Re: [go-nuts] encode struct as JSON, and use it in http.NewRequest ( io.Writer vs. io.Reader issue )H

2016-10-01 Thread Shawn Milochik
How about https://golang.org/pkg/bytes/#NewReader ? -- 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,

[go-nuts] Re: go/types equality rules are incredibly confusing

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 11:50:24 PM UTC+8, Nate Finch wrote: > > There are a couple details to how go/types.Type values compare that I > think need better documentation. Ideally there would be some programmatic > improvement, but that might not be possible. > > First: go/types.Type

[go-nuts] Re: go/types equality rules are incredibly confusing

2016-10-01 Thread Nate Finch
That's a tutorial, not documentation. It would have been useful to have that information in the godoc. I agree it was a mistake to use a Type as a map key, but the fact that it does work for some Types was what was confusing (along with same types from different loaders not being Identical).

[go-nuts] Re: go/types equality rules are incredibly confusing

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 12:25:02 AM UTC+8, Nate Finch wrote: > > That's a tutorial, not documentation. It would have been useful to have > that information in the godoc. > > I agree it was a mistake to use a Type as a map key, but the fact that it > does work for some Types was what

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

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 4:28 PM T L wrote: > I know this byte and uint8 are identical in syntax. They are identical semantically. > But they are not defined with TypeSpec style described in the go spec. It's not possible to

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

2016-10-01 Thread 'Axel Wagner' via golang-nuts
It *is* possible to define two named types with the same name (which are not identical according to the spec): https://play.golang.org/p/PmkcvdNQnx On Sat, Oct 1, 2016 at 5:03 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Sat, Oct 1, 2016 at 4:28 PM T L wrote: > > > I know

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

2016-10-01 Thread T L
On Saturday, October 1, 2016 at 10:07:02 PM UTC+8, Jan Mercl wrote: > > > > but we even don't know how the builtin byte and uint8 are defined? > > Yes we know, see: https://golang.org/ref/spec#Numeric_types > I know this byte and uint8 are identical in syntax. But they are not defined with

[go-nuts] Cast from int to uint64 performance cost

2016-10-01 Thread agniva . quicksilver
Hello, I am using a variable to track the no. of bytes written to a file so far. Now the fmt.Fprint command returns the bytes written as int. But I am thinking of storing the value as a uint64 just to give it some extra space. Therefore, I have to do a bytesWritten += uint64(n) to add to the

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 8:55 AM, T L wrote: > > On Saturday, October 1, 2016 at 11:29:35 PM UTC+8, Axel Wagner wrote: >> >> It *is* possible to define two named types with the same name (which are >> not identical according to the spec): >> https://play.golang.org/p/PmkcvdNQnx

[go-nuts] encode struct as JSON, and use it in http.NewRequest ( io.Writer vs. io.Reader issue )H

2016-10-01 Thread Lax Clarke
Hi, I want to marshall a struct as JSON and use it in an http.NewRequest. The problem is, encoding/json package provides NewEncoder, but that works on an io.Writer (see: https://golang.org/pkg/encoding/json/#NewEncoder) While, http.NewRequest accepts an io.Reader as the body of request. (see:

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

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 11:34:41 AM UTC+8, Matt Harden wrote: > > 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

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 9:21 PM, T L wrote: > > On Sunday, October 2, 2016 at 12:17:05 PM UTC+8, Ian Lance Taylor wrote: >> >> On Sat, Oct 1, 2016 at 10:56 AM, T L wrote: >> > >> > On Sunday, October 2, 2016 at 12:38:00 AM UTC+8, Ian Lance Taylor wrote: >>

[go-nuts] OpenWRT-friendly golang hardware

2016-10-01 Thread Sokolov Yura
Some uses gccgo for mips hardware. -- 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

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

2016-10-01 Thread Matt Harden
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 that uint8 and byte originate in the

Re: [go-nuts] encode struct as JSON, and use it in http.NewRequest ( io.Writer vs. io.Reader issue )H

2016-10-01 Thread Matt Harden
You could use bytes.Buffer to encode it into a buffer beforehand and then pass that as the body, or you could use an io.Pipe which essentially connects a Reader to a Writer, which allows you to encode on the fly as the http client reads the body to send it along. However I think encoding/json may

[go-nuts] Re: vender folder problem

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 12:07:06 PM UTC+8, 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_golang/prometheus" > > > error while compile with

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

2016-10-01 Thread T L
On Sunday, October 2, 2016 at 12:24:24 PM UTC+8, Ian Lance Taylor wrote: > > On Sat, Oct 1, 2016 at 9:21 PM, T L > wrote: > > > > On Sunday, October 2, 2016 at 12:17:05 PM UTC+8, Ian Lance Taylor wrote: > >> > >> On Sat, Oct 1, 2016 at 10:56 AM, T L

[go-nuts] vender folder problem

2016-10-01 Thread topiyadharesh
I have two import packages and have it in vendor dir. kitprometheus "github.com/go-kit/kit/metrics/prometheus" stdprometheus "github.com/prometheus/client_golang/prometheus" error while compile with go1.7: "github.com/bla/bla/vendor/github.com/go-kit/kit/metrics".Counter does not implement

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

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 10:56 AM, T L wrote: > > On Sunday, October 2, 2016 at 12:38:00 AM UTC+8, Ian Lance Taylor wrote: >> >> On Sat, Oct 1, 2016 at 8:55 AM, T L wrote: >> > >> > On Saturday, October 1, 2016 at 11:29:35 PM UTC+8, Axel Wagner wrote: >> >>

Re: [go-nuts] Cast from int to uint64 performance cost

2016-10-01 Thread Ian Lance Taylor
On Sat, Oct 1, 2016 at 12:24 AM, wrote: > > I am using a variable to track the no. of bytes written to a file so far. > Now the fmt.Fprint command returns the bytes written as int. But I am > thinking of storing the value as a uint64 just to give it some extra