Live data from Hacker News

Six years of Go

blog.golang.org

241–250 of 327 posts

Re: Six years of Go

#241

Earlier quoted context omitted.

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

Have you seen this blog post by Rob Pike? https://blog.golang.org/errors-are-values

This is very worth reading – it does offer some insight into the design process. In practice, there's still a lot of boilerplate error handling, but treating errors as values does help.

Re: Six years of Go

#242
post #219

Earlier quoted context omitted.

It does look better, but `value` will only be accessible inside the block. That's a no-go if you want to perform actions with `value` below.

That is iff you use the shorthand declaration-assign: https://play.golang.org/p/6uGmPZIu4S

Correct, which is what the parent was asking about. :)

Re: Six years of Go

#243
post #227

Earlier quoted context omitted.

On the other had, Google could kill Go tomorrow...

How? Its an open source project: https://github.com/golang/go

Google represents what 95%+ of the committers ?

If you took those away not to mention the message it would send to everyone would be enough to put the language in a death spiral. Good luck convincing management to use a language that even Google abandoned.

Re: Six years of Go

#244

I have a bit of a love-hate relationship going on with Go. On one hand, it addresses many of the pain points I've experienced with other languages. It's easy to build and deploy, reasonably performant, and has a powerful and consistent standard library. On the other… developing in it feels like a total slog. It manages to be simultaneously far too anal and overly forgiving about syntax. Visibility definition using up…

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

If there a paradigm for handling multiple potential errors in a function?

I'm usually stuck using:

  reply, err := redis.Givemethevalue(key)

  if err != nil {
    return err
  }

  thing, err2 := postgres.getById(reply)

  if err2 != nil {
    return err2
  }

Re: Six years of Go

#245

I've used Go for a couple years but am only just writing my first production system in Go. I think one of the major complaints is that it's use-cases are ambiguous to beginners. Go, IMO, is a systems language and should not be the first thing you pull out when someone says "write a web app". I think Go has a very limited use case, but it is incredibly good for that use case. If I had to define it right now it would b…

Really agree with this. Its not my go-to language for many things that could be done with a simple script, but its good to have it in the toolbox when i do have those sort of problems. I think if i was writing a high-performance API i would use Go

Re: Six years of Go

#246

I have a bit of a love-hate relationship going on with Go. On one hand, it addresses many of the pain points I've experienced with other languages. It's easy to build and deploy, reasonably performant, and has a powerful and consistent standard library. On the other… developing in it feels like a total slog. It manages to be simultaneously far too anal and overly forgiving about syntax. Visibility definition using up…

> particularly high-performance small services that do things like fling JSON around :/ Their json system reflects and allocates like a mad-man. It's probably one of the slowest parts of the std library.

Yes, this is a good point (and I've hit this in the builtin XML unmarshalling too). I should point out I'm mostly looking at go in comparison with Ruby rather than the C, so the JSON implementation is still high-performance by that metric :)

Re: Six years of Go

#247

Earlier quoted context omitted.

You either "get" Go or you don't. Which shouldn't be surprising given that it is a very opinionated language. A diagnostic indicator is whether you gravitate towards things like Martini or Gin, which aren't idiomatic Go and seem designed to ease the pain of using Go for those who don't actually care for it much.

Curious your opinion on what you would advise if not Martini or Gin? I love martini (and lately gin) and definitely love and use go every day. What about these frameworks is not idiomatic go? Is there another framework that is? Or you suggest just rolling your own using net/http by itself? Cheers

I remember awhile ago Martini used to have a large performance hit that Gin didn't. I think it had something to do with the url multiplexer, wouldn't be surprised if it's since been fixed but it was the reason I initially chose Gin when I first started writing Go.

Re: Six years of Go

#248

Earlier quoted context omitted.

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

If there a paradigm for handling multiple potential errors in a function? I'm usually stuck using: reply, err := redis.Givemethevalue(key) if err != nil { return err } thing, err2 := postgres.getById(reply) if err2 != nil { return err2 }

Yes:

  reply, err := redis.Givemethevalue(key)
  if err != nil {
    return err
  }

  thing, err := postgres.getById(reply)
  if err != nil {
    return err
  }
Go allows you to assign with := if at least one of the left-hand-side variables is new.

Re: Six years of Go

#249

I recently implemented a RESTful resource mapper in go, which just accepts some basic parameters and an exemplar of a storable structure and wires up all the HTTP endpoints necessary to give users CRUD access to the resource. I'm honestly very happy with how straightforward it was, even lacking generics---I solved the problem of no generics by basing the resource creation and management on JSON and a "Storable" inter…

Would you care to share some code example?

Re: Six years of Go

#250

I have a bit of a love-hate relationship going on with Go. On one hand, it addresses many of the pain points I've experienced with other languages. It's easy to build and deploy, reasonably performant, and has a powerful and consistent standard library. On the other… developing in it feels like a total slog. It manages to be simultaneously far too anal and overly forgiving about syntax. Visibility definition using up…

You either "get" Go or you don't. Which shouldn't be surprising given that it is a very opinionated language. A diagnostic indicator is whether you gravitate towards things like Martini or Gin, which aren't idiomatic Go and seem designed to ease the pain of using Go for those who don't actually care for it much.

After a day of writing Go, I certainly gravitate towards martini and gin!
Post reply on HN