[go-nuts] Re: Ternary ... again

2018-08-16 Thread bassrob
I disagree with the argument that a simple ternary could become unwieldy as a reason not to introduce it to a language. People should be trusted (just as they are now with other constructs) to use a more suitable construct or to refactor when a given one fails to scale. The fact that the Guild

[go-nuts] a tool to add struct keys to struct literals globally

2018-08-16 Thread Dan Kortschak
Does anyone know of a source manipulation tool that will add struct keys to source code, similar to honnef.co/go/tools/cmd/keyify but operating on an entire file rather than just at a specific offset? thanks Dan -- You received this message because you are subscribed to the Google Groups "golan

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread 'Kean Ho Chew' via golang-nuts
On Friday, August 17, 2018 at 8:53:15 AM UTC+8, Liam wrote: > > I find that one-concept-per-line, yielding more compact functions, is > easier to focus on, as it reduces vertical eye scanning and scrolling. > > A single-line if stmnt and my switch example demonstrate > one-concept-per-line. > > T

Re: [go-nuts] Concurrency Problems

2018-08-16 Thread Yuansheng Wu
https://gobyexample.com/ has some good examples -- Best Regards Eddy wuyuansheng.com Bestsdfasfasdfdsd On Thu, Aug 16, 2018 at 9:01 AM Rajat Jain wrote: > Hi, > > I'm looking to solve interesting problems on concurrency in golang to > understand channels/goroutines better. Can anyone sugges

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Hoo Luu
Yep, the problem is due largely to gofmt. Ternary operator is easily misused and hard to read if it is nested. That's why i prefer if expression(without needing to add a new operator and even if it was deep nested in the worst case, its complexity would equal a deep nested if statement,its read

Re: [go-nuts] Delve 1.1.0 is released

2018-08-16 Thread Sameer Ajmani
Congrats! Lots of new DWARF improvements in Go 1.11; thanks for working with us to make these great! On Thu, Aug 16, 2018 at 7:02 PM Derek Parker wrote: > Announcing Delve v1.1.0! > Tons of fixes and improvements including: * Go 1.11 support * Initial > support for function & method calls (still

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Liam Breck
I find that one-concept-per-line, yielding more compact functions, is easier to focus on, as it reduces vertical eye scanning and scrolling. A single-line if stmnt and my switch example demonstrate one-concept-per-line. go fmt aspires to produce an odd sort of poetry, which I find inefficient. It

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Christopher Nielsen
How is a ternary more readable? I've found that they make code more complex and unreadable, in both C and the proposed go, and the one-liner you provide is equally or more unreadable than the more verbose if statement. On Thu, Aug 16, 2018, 16:55 Liam Breck wrote: > Indeed, the problem is largel

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Liam Breck
Indeed, the problem is largely go fmt, I already raised this, but no one picked up on it: I use this one-liner: v := a; if t { v = b } This is not compatible with go fmt, but that tool's effects are undocumented (see issue 18790 which was declined), an

Re: [go-nuts] Limit goroutine resource usage?

2018-08-16 Thread 'Keith Randall' via golang-nuts
There's no equivalent of the methods you mentioned. You can't limit a goroutine from another goroutine, because (among other reasons) there's no way to name it. A goroutine can limit itself a bit by calling runtime.Gosched, or more forcefully using time.Timer. Andrey's suggestion of limiting ho

[go-nuts] Re: Local repository for go modules

2018-08-16 Thread thepudds1460
"There is no VCS, only a tree in my own file system." Hi Ignazio, I think you could go down the Athens path if you wanted to, but I don't think you need to do so. I suspect the 'replace' directive I described in my earlier post in this thread might be sufficient for what you describe, becau

[go-nuts] Delve 1.1.0 is released

2018-08-16 Thread Derek Parker
Announcing Delve v1.1.0! Tons of fixes and improvements including: * Go 1.11 support * Initial support for function & method calls (still new, still improving) * New commands / options * Logging improvements * A lot more! Check out the full changelog here

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Matthias B.
On Wed, 15 Aug 2018 07:46:51 -0700 (PDT) Hoo Luu wrote: > 在 2018年8月15日星期三 UTC+8上午12:43:37,Mark Volkmann写道: > > > var color = temperature > 100 ? “red” : “blue” > > > Although this feature will not be accepted, we could just talk about > it. I prefer 'if-expression' to ternary. > > var c

[go-nuts] Re: Local repository for go modules

2018-08-16 Thread Ignazio Di Napoli
On Thursday, August 16, 2018 at 8:20:10 PM UTC+2, thepud...@gmail.com wrote: > > Could you say a few more words about your use case? > Thank you. Looking at design docs, I think Athens can do what I'm looking for, but maybe it is a little "too much", and either docs are incomplete or I'm unable

[go-nuts] Re: Ternary ... again

2018-08-16 Thread haskell_mustard via golang-nuts
color := colorFor(temperature) func colorFor(temperature int) string { if temperature > 100 { return "red" } return "blue" } On Thursday, 16 August 2018 18:01:20 UTC+2, Haddock wrote: > > > var color >> if temperature > 100 { >> color = “red” >> } else { >> color = “blue” >> } >> >

[go-nuts] [ANN] bplint - linter tool for Bitpeek format strings

2018-08-16 Thread Wojciech S. Czarnecki
Bplint looks through given go source files for occurrence of tagged Bitpeek format strings then it checks every found one for common pitfalls. Bplint also prints on the console clear mapping from the picstring to input's bits: ``` $ bplint -m ampl bplint_test.go --- Pic: "Example" in bplint_test

[go-nuts] go mod: x/net,etc repos need version tags

2018-08-16 Thread Liam Breck
Retry under clarified subject... I could not find a version number for x/net or x/net/ipv4. If none exists, > could the maintainers start committing version tags for each submodule in > golang.org/x -- i.e. x/*/* (or x/* if no submodules)? > > This will benefit the imminent rush of *go mod* users

Re: [go-nuts] Decoding the buffer to a struct sent from C program

2018-08-16 Thread Naveen Neelakanta
Thanks, I was able to solve the problem with the below code and changing the type to byte. if err := binary.Read(ConnErr, binary.BigEndian, &data); err != nil { Log.ErrS("Error reading notification message", log.KV{"err": err}) break

[go-nuts] Re: Local repository for go modules

2018-08-16 Thread thepudds1460
Hi Ignazio, Athens is one option, but there are also possible options depending on what you are trying to accomplish. Could you say a few more words about your use case? If you are doing something simple, like experimenting with creating a hello world module in something like /tmp/hello, then

[go-nuts] Re: Local repository for go modules

2018-08-16 Thread Zellyn
I think Project Athens is what you want? https://github.com/gomods/athens On Thursday, August 16, 2018 at 12:12:11 PM UTC-4, Ignazio Di Napoli wrote: > > I'd like to experiment with modules, in a local directory. I know I can do > it setting GOPROXY to a file:/// url. > But what about looking fo

[go-nuts] Local repository for go modules

2018-08-16 Thread Ignazio Di Napoli
I'd like to experiment with modules, in a local directory. I know I can do it setting GOPROXY to a file:/// url. But what about looking for my own modules in a local folder, and the others normally (optionally through the proxy)? Is there a simple proxy I can configure in this way? Thank you.

[go-nuts] New meetup in Sheffield

2018-08-16 Thread Daniel Martí
Hi all, I have just started a Go meetup in Sheffield, England: https://www.meetup.com/GoSheffield/ Feel free to sign up if you live nearby or would visit from time to time - regular meetups will begin next month :) Thanks! -- You received this message because you are subscribed to the Google

Re: [go-nuts] Decoding the buffer to a struct sent from C program

2018-08-16 Thread Jan Mercl
On Thu, Aug 16, 2018 at 5:29 AM wrote: > char str[384]; > Str [384]string The counterpart to C.char is uint8 aka byte. IOW struct foo { char bar[42]; } corresponds to type foo struct { bar [42]byte } -- -j -- You received this message because you are subscribed to the Go

[go-nuts] Re: Decoding the buffer to a struct sent from C program

2018-08-16 Thread jake6502
Perhaps someone can spot the error just by looking at your code. But a couple of tips that will help others help you. 1. Specify what exactly the "failure" is. What output do you get? 2. Include the log output for a sample run. 3. Print, and include a sample value of "data" (the binary data from

[go-nuts] Re: Ternary ... again

2018-08-16 Thread Haddock
If you think this discussion is taking a lot of time have a look at the same discussion for Kotlin in their user group: https://discuss.kotlinlang.org/t/ternary-operator/2116/95 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe fro

[go-nuts] Concurrency Problems

2018-08-16 Thread Rajat Jain
Hi, I'm looking to solve interesting problems on concurrency in golang to understand channels/goroutines better. Can anyone suggest a good website/collection of problems. Thanks, Rajat -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubs

[go-nuts] Re: Ternary ... again

2018-08-16 Thread ffm2002
> var color > if temperature > 100 { > color = “red” > } else { > color = “blue” > } > IMHO, it could be argued about whether adding something like this would be useful: color := if temperature > 100 { return “red” } else { return “blue” } -- You received this mess

Re: [go-nuts] Re: Server RAM size as a function of the number of goroutines???

2018-08-16 Thread faizan khan
thanks, thats what I was recommended from the slack channel discussion as well cheers, Faizan On Thu, Aug 16, 2018 at 12:06 PM, Gernot Reisinger < gernot.reisin...@gmail.com> wrote: > If I understood your scenario correctly, I would assume that it is not the > Goroutines overhead per se but

Re: [go-nuts] Can go-dockerclient be built with go modules?

2018-08-16 Thread Joseph Lorenzini
Hi Peter, Thanks that was very helpful. That issue describes my problem exactly. Frankly, IMHO, the issue isn’t so much modules being buggy as docker being a project with poorly managed versioning. It’s some of the worst I have ever see. For example, I don’t understand why they haven’t added a gi

Re: [go-nuts] Why "strings" package exists ?

2018-08-16 Thread isfrog
Thank you, Ian. 在 2018年8月15日星期三 UTC+8下午12:36:31,Ian Lance Taylor写道: > > On Tue, Aug 14, 2018 at 7:37 PM, > wrote: > > > > Why not define the methods on type "string" ? > > I look up the document, strings package handles string with UTF-8 > encoding. > > is it the reason ? > > if not, it's

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread Giulio Iotti
On Thursday, August 16, 2018 at 11:59:00 AM UTC+3, Axel Wagner wrote: > > func either(c bool, a, b func() string) string { > if c { > return a() > } > return b() > } > > func thunk(s string) func() string { > return func() string { return s } > } > > fmt.Printf("color is %s"

Re: [go-nuts] Ternary ... again

2018-08-16 Thread Peter Waller
On Wed, 15 Aug 2018 at 12:44, peterGo wrote: > Remember the Vasa! http://www.stroustrup.com/P0977-remember-the-vasa.pdf > That note from Stroustroup is profound. Thanks for sharing. Personally, I'm glad that we have a language where the philosophy is "What is the minimum feature-set which allows

Re: [go-nuts] Ternary ... again

2018-08-16 Thread Jesper Louis Andersen
On Tue, Aug 14, 2018 at 6:43 PM Mark Volkmann wrote: > I’m new to Go and I imagine the idea of adding a ternary operator to Go > has been discussed many times. Rather than repeat that, can someone point > me to a discussion about why Go doesn’t add this? I’m struggling to > understand why it is d

Re: [go-nuts] Can go-dockerclient be built with go modules?

2018-08-16 Thread Peter Waller
Another issue worth consulting, https://github.com/golang/go/issues/26208, which isn't yet marked as resolved. -- 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 gol

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread 'Axel Wagner' via golang-nuts
func either(c bool, a, b func() string) string { if c { return a() } return b() } func thunk(s string) func() string { return func() string { return s } } fmt.Printf("color is %s", either(temperature > 100, thunk("red"), thunk("blue")) ;) On Thu, Aug 16, 2018 at 10:53 A

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread roger peppe
In my experience, this is rarely a real pain, and where it is, a simple function can help out. func either(condition bool, a, b string) string { if condition { return a } return b } fmt.Printf("color is %s", either(temperature>100, "red", "blue"))

Re: [go-nuts] Re: Ternary ... again

2018-08-16 Thread 'Axel Wagner' via golang-nuts
Hi Sam. A couple small responses inline. On Thu, Aug 16, 2018 at 8:13 AM Sam Vilain wrote: > To me the biggest reason to want a ternary operator is to make it easier > on the reader of the code. If there's anything that go and python have in > common, it's that both languages are designed to be

Re: [go-nuts] Ternary ... again

2018-08-16 Thread Wojciech S. Czarnecki
On Tue, 14 Aug 2018 05:43:07 -0500 Mark Volkmann wrote: > I’m new to Go and I imagine the idea of adding a ternary operator to Go has > been discussed many times. Rather than repeat that, can someone point me to > a discussion about why Go doesn’t add this? > I’m struggling to understand why it

Re: [go-nuts] Ternary ... again

2018-08-16 Thread 'Kean Ho Chew' via golang-nuts
> > The first is ternaries. What if only simple, non-nested ternaries were > supported? For example, color := temperature > 100 ? “red” : “blue”. This > seems so much more clear than the map[bool]:string trick that some have > proposed. Writing this with an if statement takes either 4 or 6 line

Re: [go-nuts] Re: AWS S3 Image Upload with Golang

2018-08-16 Thread Steven Hartland
If your file out code is above your original code snippet so you have something like: https://play.golang.org/p/5MVxJamHy4c Then one of the problems is the file pointer of "out" points to the end of your file not the beginning. If you don't need the file on disk then something like the follow

Re: [go-nuts] Re: Extending deadline for logging

2018-08-16 Thread Dave Cheney
Thinking some more about the problem, I think your solution of reserving some of the deadline to handle the spanner log in the error case sounds like the best answer. However it does lead to questions like, if you reserve n seconds to log to spanner in the error path, and it takes longer than n

[go-nuts] Re: Server RAM size as a function of the number of goroutines???

2018-08-16 Thread Gernot Reisinger
If I understood your scenario correctly, I would assume that it is not the Goroutines overhead per se but the traceroute command processes spawned in the Goroutines that drives the resource demand. The pure Goroutine memory overhead should be quite neglectable (size of G struct + initial dynamic