Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread Tamás Gulácsi
See ragel for an fsm generator! -- 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 https://groups.g

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread roger peppe
On 24 August 2017 at 06:39, Bakul Shah wrote: > On Wed, 23 Aug 2017 12:11:41 BST roger peppe wrote: >> On 23 August 2017 at 11:20, Bakul Shah wrote: >> > >> > I find regular functions much cleaner (and a closer analog of >> > a digital FSM). See for example: > ... >> > func stateOne(i i

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-23 Thread Henrik Johansson
Of course you are right Ian, there is nothing inherently wrong with experience reports. That's never what I meant to say and if that's how it came off I am sorry. It has been bugging me a little though that pre GopherCon it was "proposal or nothing" and post GopherCon it is "experience reports or

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread Bakul Shah
On Wed, 23 Aug 2017 12:11:41 BST roger peppe wrote: > On 23 August 2017 at 11:20, Bakul Shah wrote: > > > > I find regular functions much cleaner (and a closer analog of > > a digital FSM). See for example: ... > > func stateOne(i inputType) state { > > // etc. etc. > >

[go-nuts] Re: can you help me? I have a problem.

2017-08-23 Thread 王晚成
Thanks very much ,I have solved it 在 2017年8月24日星期四 UTC+8上午3:23:08,JuciÊ Andrade写道: > > My dear friend 王晚成 , > > You ask about the padchar parameter. That is the character used for > filling the space between columns. > The meaning of tabwidth is not so simple. To understand that you should > lea

[go-nuts] Re: can you help me? I have a problem.

2017-08-23 Thread 王晚成
Thanks very much ,I have solved it 在 2017年8月24日星期四 UTC+8上午1:23:08,王晚成写道: > > func (b *Writer ) Init(output > io .Writer , > minwidth, tabwidth, padding int

[go-nuts] Re: can you help me? I have a problem.

2017-08-23 Thread 王晚成
Thanks very much ,I have solved it 在 2017年8月24日星期四 UTC+8上午3:23:08,JuciÊ Andrade写道: > > My dear friend 王晚成 , > > You ask about the padchar parameter. That is the character used for > filling the space between columns. > The meaning of tabwidth is not so simple. To understand that you should > lea

Re: [go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread djadala
Agree about hidden assumption, and may be alignment issues. Last try: https://play.golang.org/p/6e-i0AFZri Jamil Djadala On Thursday, August 24, 2017 at 1:40:52 AM UTC+3, Rob 'Commander' Pike wrote: > > Apologies, typo. This is it: https://play.golang.org/p/9XWoCiUH2D > > On Thu, Aug 24, 2017

Re: [go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread Rob Pike
Apologies, typo. This is it: https://play.golang.org/p/9XWoCiUH2D On Thu, Aug 24, 2017 at 8:39 AM, Rob Pike wrote: > I believe there is no safe (that is, unsafe-free) way to discover the > native byte order. In a sense, this is because depending on the native > byte order is intrinsically unsafe.

Re: [go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread Rob Pike
I believe there is no safe (that is, unsafe-free) way to discover the native byte order. In a sense, this is because depending on the native byte order is intrinsically unsafe. It is by definition not portable. It is a terrible design decision. By the way, that program may work but it's not sound.

Re: [go-nuts] Golang 1.9 release ETA update?

2017-08-23 Thread Steven Hartland
On 23/08/2017 23:16, Ian Lance Taylor wrote: On Wed, Aug 23, 2017 at 1:23 AM, Steven Hartland wrote: Hi guys I see there's three issues still pending in the 1.9 milestone. The one being at test case failure on darwin which now has a skip in and the other two are doc fixes, so I was wondering if

[go-nuts] Re: Reading bytes into uint32

2017-08-23 Thread djadala
It use unsafe, but works even in playground: https://play.golang.org/p/S1rw157M9C On Wednesday, August 23, 2017 at 3:49:39 PM UTC+3, Christian von Kietzell wrote: > > Hi, > > I've stumbled across a problem I don't know how to solve. > > I'm trying to read (from stdin) four bytes into a uint32

Re: [go-nuts] Golang 1.9 release ETA update?

2017-08-23 Thread Ian Lance Taylor
On Wed, Aug 23, 2017 at 1:23 AM, Steven Hartland wrote: > Hi guys I see there's three issues still pending in the 1.9 milestone. The > one being at test case failure on darwin which now has a skip in and the > other two are doc fixes, so I was wondering if we have a likely release date > yet? > >

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-23 Thread Ian Lance Taylor
On Wed, Aug 23, 2017 at 1:30 AM, Henrik Johansson wrote: > > Sure, I am a bit short in this but again my opinion is that experience > reports wrt generics will only emphasize what is already known. That may in > itself be a metric and of value. That may well happen and you are right to call it ou

[go-nuts] Simple url shortener service

2017-08-23 Thread douglas
i have created a simple url shortener service, for practice and learn with go, what do you think ! https://github.com/douglasmakey/ursho -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails f

Re: [go-nuts] Reading bytes into uint32

2017-08-23 Thread Rob Pike
I know the use of native byte order didn't come from you, but that's lazy and wrong. https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html -rob On Thu, Aug 24, 2017 at 12:12 AM, Wojciech S. Czarnecki wrote: > On Wed, 23 Aug 2017 10:51:25 +0200 > Christian von Kietzell wrote: > >>

Re: [go-nuts] Re: net.Dial seems to ignore /etc/hosts if I don't provide GODEBUG=netdns=(c)go

2017-08-23 Thread cpuguy83
I'm not sure I agree that this is an alpine bug. This seems to be defined here: https://golang.org/src/net/conf.go#L203 // If /etc/nsswitch.conf doesn't exist or doesn't specify any // sources for "hosts", assume Go's DNS will work fine. if os.IsNotExist(nss.err) || (nss.err =

[go-nuts] Unmarshal unknown fields into json.RawMessage

2017-08-23 Thread Karthik Rajagopalan
Hi Folks, In unmarshaling json, I like to retain the unknown fields as json.RawMessage and just decode the known fields. Is it possible through json tag? type Decode struct { Etag string `json:"etag"` ContentLength int `json:"contentLength"` UnknownFields *json.RawMessage } -Kar

[go-nuts] Re: can you help me? I have a problem.

2017-08-23 Thread ojucie
My dear friend 王晚成 , You ask about the padchar parameter. That is the character used for filling the space between columns. The meaning of tabwidth is not so simple. To understand that you should learn the algorithm. Please read this: http://nickgravgaard.com/elastic-tabstops/ After getting a

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread Steven Blenkinsop
On Wed, Aug 23, 2017 at 6:20 AM Bakul Shah wrote: > This is a Mealy machine, where the next state > depends on the current state and current input (in s/w not > much use for a Moore machine unless you are driving/simulating > some regular physical process, in which case you don't need > any input

[go-nuts] Re: Next generation code generator for go

2017-08-23 Thread Walter Schulze
https://news.ycombinator.com/item?id=15083381 On Wednesday, 23 August 2017 18:00:49 UTC+2, Walter Schulze wrote: > > Thank you very much for the compliments and support. > I really appreciate it. > > On Wednesday, 23 August 2017 16:35:29 UTC+2, mhh...@gmail.com wrote: >> >> coolest repo to watch a

[go-nuts] can you help me? I have a problem.

2017-08-23 Thread hellomanong
func (b *Writer ) Init(output io .Writer , minwidth, tabwidth, padding int , padchar byte , flags uint

[go-nuts] Re: Next generation code generator for go

2017-08-23 Thread Walter Schulze
Thank you very much for the compliments and support. I really appreciate it. On Wednesday, 23 August 2017 16:35:29 UTC+2, mhh...@gmail.com wrote: > > coolest repo to watch at that moment > > On Wednesday, August 23, 2017 at 9:38:42 AM UTC+2, Walter Schulze wrote: >> >> I created gogoprotobuf, but

[go-nuts] Re: Next generation code generator for go

2017-08-23 Thread mhhcbon
coolest repo to watch at that moment On Wednesday, August 23, 2017 at 9:38:42 AM UTC+2, Walter Schulze wrote: > > I created gogoprotobuf, but I wanted to create a new code generator for go > that does not only work for protocol buffers, but for all go types. > > Here is my next generation code ge

Re: [go-nuts] Reading bytes into uint32

2017-08-23 Thread Wojciech S. Czarnecki
On Wed, 23 Aug 2017 10:51:25 +0200 Christian von Kietzell wrote: > [*1] The data comes from a web browser extension using the native > messaging API, which specifies that messages sent to external programs > are prefixed with the 32-bit length of the message in native byte order. I understand th

[go-nuts] Re: Next generation code generator for go

2017-08-23 Thread ojucie
Thank you, Walter. It's a nice tool, to say the least. -- 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] Reading bytes into uint32

2017-08-23 Thread Tamás Gulácsi
See https://github.com/tsuna/endian Tl;Dr use tags to decide which one to use. -- 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...@googlegrou

[go-nuts] Re: const vs global variables in go

2017-08-23 Thread Volker Dobler
Variables and constant are totally different things. Work through https://tour.golang.org/basics/8 ff and https://tour.golang.org/basics/15 ff Memory usage and copy behaviour are not interesting until you are comfortable with the basics of the language. V. On Wednesday, 23 August 2017 14:49:39

[go-nuts] Reading bytes into uint32

2017-08-23 Thread Christian von Kietzell
Hi, I've stumbled across a problem I don't know how to solve. I'm trying to read (from stdin) four bytes into a uint32 value. Those bytes are provided in _native_ byte order by an external program.[*1] Since I've found nothing in the standard library to determine the machine's native byte order

[go-nuts] const vs global variables in go

2017-08-23 Thread Alkesh Ghorpade
Hi All, I am new to Go and trying to figure out difference between const vs var variables memory usage and initialization. I have following go code // way 1 var a = []string{"abc", "def"} // way 2 const ( a = "abc" b = "def" ) var a1 = []string{a, b} my variables a and a1 are define

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread roger peppe
On 23 August 2017 at 11:20, Bakul Shah wrote: > On Wed, 23 Aug 2017 09:48:14 BST roger peppe wrote: >> On 23 August 2017 at 09:40, roger peppe wrote: >> > On 23 August 2017 at 09:23, MartinG wrote: >> >> Thanks for the fantastic explanation folks. >> >> >> >> I wonder if I can ask advice on how

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread Bakul Shah
On Wed, 23 Aug 2017 09:48:14 BST roger peppe wrote: > On 23 August 2017 at 09:40, roger peppe wrote: > > On 23 August 2017 at 09:23, MartinG wrote: > >> Thanks for the fantastic explanation folks. > >> > >> I wonder if I can ask advice on how to improve my use case. I have a stru > ct > >> type

Re: [go-nuts] Next generation code generator for go

2017-08-23 Thread Henrik Johansson
For all vscode users there is https://github.com/Microsoft/vscode-go/issues/1160 to maybe vote for to get editor support. ons 23 aug. 2017 kl 10:57 skrev Walter Schulze : > Thanks, that is good to know :) > If you do, please let me know. > It would be nice to add more projects to the user list. >

[go-nuts] Golang 1.9 release ETA update?

2017-08-23 Thread Dave Cheney
Can you use 1.9rc2? It's been soak tested inside google for a few weeks now. -- 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

Re: [go-nuts] Next generation code generator for go

2017-08-23 Thread Walter Schulze
Thanks, that is good to know :) If you do, please let me know. It would be nice to add more projects to the user list. On Wed, 23 Aug 2017 at 10:17 roger peppe wrote: > This is very cool, thanks! I may well end up using this. > > On 23 August 2017 at 08:38, Walter Schulze > wrote: > > I created

Re: [go-nuts] Making sense of Go profiling output

2017-08-23 Thread Jakob Borg
On 23 Aug 2017, at 10:00, Deepak Jois wrote: > > I am profiling a Go program that calls into C using cgo, and then > tries to get a pointer to unsafe data. In the profiling, I see that > over 62% of the time is spent in a call which is of the form > > func getBytes(val *C.MDB_val) []byte { >

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread roger peppe
On 23 August 2017 at 09:40, roger peppe wrote: > On 23 August 2017 at 09:23, MartinG wrote: >> Thanks for the fantastic explanation folks. >> >> I wonder if I can ask advice on how to improve my use case. I have a struct >> type that represents a state machine and each state is handled by a >> d

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread roger peppe
On 23 August 2017 at 09:23, MartinG wrote: > Thanks for the fantastic explanation folks. > > I wonder if I can ask advice on how to improve my use case. I have a struct > type that represents a state machine and each state is handled by a > different method on that type, each with the same signat

Re: [go-nuts] Re: Gathering Ideas for Go 2.

2017-08-23 Thread Henrik Johansson
ons 23 aug. 2017 kl 08:37 skrev Florin Pățan : > On Wednesday, August 23, 2017 at 6:45:57 AM UTC+1, Henrik Johansson wrote: > > I may suffer from a "fundamental lack of understanding" about many > things but there isn't much to misunderstand in Russ blog post. I have also > seen the talk. I simply

[go-nuts] Golang 1.9 release ETA update?

2017-08-23 Thread Steven Hartland
Hi guys I see there's three issues still pending in the 1.9 milestone. The one being at test case failure on darwin which now has a skip in and the other two are doc fixes, so I was wondering if we have a likely release date yet? The reason I ask is our production system is being hit regularly

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-23 Thread MartinG
Thanks for the fantastic explanation folks. I wonder if I can ask advice on how to improve my use case. I have a struct type that represents a state machine and each state is handled by a different method on that type, each with the same signature I use a function variable to represent the cu

Re: [go-nuts] Next generation code generator for go

2017-08-23 Thread roger peppe
This is very cool, thanks! I may well end up using this. On 23 August 2017 at 08:38, Walter Schulze wrote: > I created gogoprotobuf, but I wanted to create a new code generator for go > that does not only work for protocol buffers, but for all go types. > > Here is my next generation code generat

[go-nuts] Making sense of Go profiling output

2017-08-23 Thread Deepak Jois
I am profiling a Go program that calls into C using cgo, and then tries to get a pointer to unsafe data. In the profiling, I see that over 62% of the time is spent in a call which is of the form func getBytes(val *C.MDB_val) []byte { return (*[valMaxSize]byte)(unsafe.Pointer(val.mv_data))[:va

[go-nuts] Next generation code generator for go

2017-08-23 Thread Walter Schulze
I created gogoprotobuf, but I wanted to create a new code generator for go that does not only work for protocol buffers, but for all go types. Here is my next generation code generation for go: https://github.com/awalterschulze/goderive goderive parses your go code for functions which are not imp

[go-nuts] expanderr: expands the Go Call Expression under your cursor to check errors

2017-08-23 Thread Michael Stapelberg
Hey, I just published https://github.com/stapelberg/expanderr and thought some of you might find that tool useful. Let me know if you have any feedback, Best regards, Michael -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from t