[go-nuts] const struct

2017-09-07 Thread DrGo
Sorry if this was asked before, but I could not find any relevant posts. Any reason why this struct literal (made up of fields that can be declared const) is not allowed? const UnknownPos = scanner.Position{"", -1, -1, -1} error: const initializer scanner.Position literal is not a constant.

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Dave Cheney
> > > Wouldn't be great to have a "syntactical sugar" to make things (at least a > little bit) simpler in our beloved Go language? > >> >> no, I don't think so. Something that few in in this thread have focused on is the most important part of the go error handling story happens *before* the

[go-nuts] Feature request: override function of exists functions

2017-09-07 Thread zixu mo
In other Object Orient language, Override the exists function will be very easy. But in golang. we can not easy override . for example: I want to use the google/martian package. https://github.com/google/martian/blob/master/proxy.go func (p *Proxy) connect(req *http.Request) (*http.Response,

Re: [go-nuts] unicode constant

2017-09-07 Thread Tong Sun
Thanks a lot Ian, That is a really *clear explanation*, coming from a *helpful attitude*. Thanks. On Thu, Sep 7, 2017 at 6:13 PM, Ian Lance Taylor wrote: > On Thu, Sep 7, 2017 at 3:08 PM, Tong Sun wrote: > > > > Are unicode constant supposed to be

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Dorival Pedroso
Yes, Nigel! try/catch in Python may at times looks uglier that err != nil. I think the reason try/catch didn't bother us in C++ is that we had lots of macros to simplify the work... In Go, we don't have macros but we don't need to wrap things with "try" and just need to "recover" panics, I

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Nigel Tao
On Thu, Sep 7, 2017 at 4:00 PM, Tim Uckun wrote: > I don't see anything wrong with the try catch paradigm, Try-catch makes for shorter code when you're just passing the buck, but it can be quite complicated when you actually need to handle the buck. My showcase example for

Re: [go-nuts] shiny driver.Main not returning

2017-09-07 Thread Nigel Tao
For the record, the OP filed https://github.com/golang/go/issues/21796 -- 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.

[go-nuts] Understanding unicode range, especially CJK

2017-09-07 Thread Tong Sun
I know the unicode range for CJK is messy (https://github.com/go-cc/cc-table/tree/master/text/info/UnicodeCJK), so I'm glad to found the `*unicode.Han*` range definition in Go. My questions are, - Is there also a range definition for CJK as a whole as well? - Has unicode.Han taken into

[go-nuts] Re: Bug or Feature? Garbage Collection relating to 'range' and 'channel'

2017-09-07 Thread Dave Cheney
Any program that uses runtime.GC for correctness has a bug :) -- 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

Re: [go-nuts] 『Q』How to make hugepagesize work with Go?

2017-09-07 Thread Ian Lance Taylor
On Mon, Sep 4, 2017 at 9:16 PM, Linker wrote: > Hi, Guys! > I have a lot of docker running go micro-services which have a big-heap. > My question is how to make go work with hugepagesize in linux/amd64 ? Go already uses huge pages on GNU/Linux when possible. If you are

Re: [go-nuts] unicode constant

2017-09-07 Thread Jan Mercl
On Fri, Sep 8, 2017 at 12:09 AM Tong Sun wrote: https://play.golang.org/p/FD8UMrDkf- > How can I make it works? Follow the language specification. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] unicode constant

2017-09-07 Thread Ian Lance Taylor
On Thu, Sep 7, 2017 at 3:08 PM, Tong Sun wrote: > > Are unicode constant supposed to be specified differently? > What's wrong with the following code? > https://play.golang.org/p/5UCmbKSIej > > How can I make it works? \u must be followed by exactly 4 hex digits. \U must be

[go-nuts] unicode constant

2017-09-07 Thread Tong Sun
Hi, Are unicode constant supposed to be specified differently? What's wrong with the following code? https://play.golang.org/p/5UCmbKSIej How can I make it works? Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Reordering of reads and writes within a goroutine

2017-09-07 Thread Ian Lance Taylor
On Thu, Sep 7, 2017 at 3:17 AM, Arpit Aggarwal wrote: > > I was going through the Go memory model at https://golang.org/ref/mem > > In the second line,first paragraph of Happens Before Description it is > written that > > * compilers and processors may reorder the reads

[go-nuts] Re: Bug or Feature? Garbage Collection relating to 'range' and 'channel'

2017-09-07 Thread T L
So it is neither a bug nor a feature. It is just that the program is not well written which makes its behavior compiler dependent. On Thursday, September 7, 2017 at 4:54:16 PM UTC-4, T L wrote: > > firstly, finalizers are never guaranteed to be run. > secondly, there are many

Re: [go-nuts] shiny driver.Main not returning

2017-09-07 Thread Dave MacFarlane
I don't have any particular insights explaining it, but I just tried adding a print after at the end of my shiny-based text editor and (at least on OS X), indeed, it never gets executed. It appears to be a bug (at the very least, a documentation bug since it explicitly says it returns.) On Thu,

[go-nuts] Re: One way - Unexported json field

2017-09-07 Thread Vincent Jouglard
Hi ascarter, This sounds like a great way to do it (even if I don't totally understand how it works, you gave me homework :D ), but, as I understand it, this would'nt work on slices ; i.e. []Player . Or I am mistaken ? Moreover, the regular rule is that the CustomField is not sent and the

Re: [go-nuts] shiny driver.Main not returning

2017-09-07 Thread Dave MacFarlane
What are you trying to do? I don't see the point in a shiny program that doesn't even create a window. There's likely a loop internally in the driver that's handling processing of events from the OS and since you're never creating a window, it's never exiting (this is just a guess, I haven't

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Wojciech S. Czarnecki
On Thu, 7 Sep 2017 05:00:18 -0700 (PDT) martin.r...@programmfabrik.de wrote: > lhow about this, and it is a construct which can be used not only for > errors: > watch err != nil { > yo1, err = do_stuff1() > yo2, err = do_stuff2() > yo3, err = do_stuff3() > } then { > // handle your error > }

[go-nuts] shiny driver.Main not returning

2017-09-07 Thread hanisch
I'm using shiny for a small internal project and noticed that driver.Main doesn't seem to return. The documentation for: func Main(f func(screen . Screen )) in golang.org/x/exp/shiny/driver

Re: [go-nuts] What's the etiquette on job postings to golang-nuts?

2017-09-07 Thread Ian Lance Taylor
On Thu, Sep 7, 2017 at 8:20 AM, Andrew Jessup wrote: > > I have a job posting that I'd like to share for an exeprienced golang > developer. Before I share it though, I wanted to know if this was the right > forum for such postings, and if not - where would be a good place to do

[go-nuts] What's the etiquette on job postings to golang-nuts?

2017-09-07 Thread Andrew Jessup
Hi folks, I have a job posting that I'd like to share for an exeprienced golang developer. Before I share it though, I wanted to know if this was the right forum for such postings, and if not - where would be a good place to do so? -- You received this message because you are subscribed to

[go-nuts] Bug or Feature? Garbage Collection relating to 'range' and 'channel'

2017-09-07 Thread ron . huafeng
package main import ( "sync" "runtime" ) type S struct { chs chan int } var wg sync.WaitGroup func worker(s *S) { for i := range s.chs { println("In worker, ch = ", i) } wg.Done() } func main() { s := S{make(chan int)} runtime.SetFinalizer(, func(ss *S) {

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread 'Axel Wagner' via golang-nuts
On Thu, Sep 7, 2017 at 2:41 PM, Tim Uckun wrote: > >I *like* the way go does error passing, *because* it's constrained to > handle errors explicitly. > > But it doesn't though. You can completely ignore the errors if you want. > > This seems to be, at best, a nit-picky

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread snmed
Hi Tim If you want halt the app, you should call panic, that's already a go built-in. Think it would apply to your proposal as well, despite i do not agree with it. Cheers snmed Am Donnerstag, 7. September 2017 14:42:12 UTC+2 schrieb Tim Uckun: > > >I *like* the way go does error passing,

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Tim Uckun
>I *like* the way go does error passing, *because* it's constrained to handle errors explicitly. But it doesn't though. You can completely ignore the errors if you want. > >TBH, no. Not only do I not know what this is supposed to be doing (err.pop? of what? Why are we assigning to error? What is

Re: [go-nuts] Tools for 80 column split for golang

2017-09-07 Thread snmed
Hi *Typically you can break your lines after comma ,, > after opening parenthesis e.g. (, [, {, and after a dot . which may be > referencing a field or method of some value. You can also break your line > after binary operators (those that require 2 operands), e.g.:* Complete answer:

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Tamás Gulácsi
I'd hate to debug this: which function has returned the error? What failed, what succeeded? -- 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

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread martin . rode
On Tuesday, September 5, 2017 at 10:39:05 AM UTC+2, Rob 'Commander' Pike wrote: > > If you find that lines like if err != nil are a significant fraction > of non-test code, your code probably needs a better error handling > strategy, not a language change. I have done measurements in the past

[go-nuts] Re: Copying slice over itself

2017-09-07 Thread peterGo
Deepak Jois, Consider this case: The Go Programming Language Specification https://golang.org/ref/spec Slice expressions https://golang.org/ref/spec#Slice_expressions Full slice expressions For an array, pointer to array, or slice a (but not a string), the primary expression a[low :

Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread peterGo
Rob, "Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff: https://play.golang.org/p/SZgpCh9D-l; a := []int{0, 1, 2, 3, 4, 5, 6, 7} s := a[1:3:5]

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread 'Axel Wagner' via golang-nuts
On Thu, Sep 7, 2017 at 8:00 AM, Tim Uckun wrote: > I don't see anything wrong with the try catch paradigm, you can choose > your granularity. If you want to check every call then you can, if you want > to let a few cluster together you can. You guys make is sound like go

[go-nuts] Reordering of reads and writes within a goroutine

2017-09-07 Thread Arpit Aggarwal
Hi everybody, I was going through the Go memory model at https://golang.org/ref/mem In the second line,first paragraph of Happens Before Description it is written that * compilers and processors may reorder the reads and writes executed within a single goroutine only when the reordering

[go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Dorival Pedroso
Agreed, Tim. This discussion helped me to realise that try/catch is pretty good; e.g. we never even bothered discussing this topic in our C++ code http://mechsys.nongnu.org/ at all... In the end of the day, we want to treat ALL errors (obviously...). Go is great that we have two approaches.

[go-nuts] Re: error handling needs syntactical sugar

2017-09-07 Thread Tim Uckun
Totally not a go programmer but here are my worthless two cents. I don't see anything wrong with the try catch paradigm, you can choose your granularity. If you want to check every call then you can, if you want to let a few cluster together you can. You guys make is sound like go style

Re: [go-nuts] Tools for 80 column split for golang

2017-09-07 Thread Sankar P
Even with most modern laptops, I found having 80 column limit is very useful, when we split panes and read code. May be it is just my personal preference :) 2017-09-07 12:05 GMT+05:30 Jakob Borg : > On 7 Sep 2017, at 06:10, Sankar wrote: > > > >

Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread Rob Pike
That test is only sufficient if the zeroth elements in the two slices are at the same address, which is often not true: https://play.golang.org/p/TH53Pxt5Do Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff:

[go-nuts] Re: Copying slice over itself

2017-09-07 Thread djadala
Hi, Just check if backing array are same before copying: https://play.golang.org/p/MSqs-jRkSO On Thursday, September 7, 2017 at 8:54:16 AM UTC+3, Deepak Jois wrote: > > Hi > > Pls look at this code: https://play.golang.org/p/QfQOo1iyp4 > > I am copying a slice over itself. How does it work

Re: [go-nuts] Tools for 80 column split for golang

2017-09-07 Thread Jakob Borg
On 7 Sep 2017, at 06:10, Sankar wrote: > > Are there any tools available for golang to split long functions so that they > can fit in 80 columns (as long as possible) ? Don't fear longer lines, most of us are not on text mode terminals any more. :) When it becomes

Re: [go-nuts] javascript libraries

2017-09-07 Thread Sebastien Binet
You could try out gonum/plot. The graphs won't be too much interactive, but that hasn't been a showstopper for me until now. Here is an example: https://GitHub.com/sbinet/go-web-examples Especially the example #7: https://github.com/sbinet/go-web-examples/tree/master/07-go-web-plot-gonum-svg