Live data from Hacker News

I Love Go; I Hate Go

dtrace.org

51–60 of 329 posts

Re: I Love Go; I Hate Go

#51
post #10

The most frustrating thing for me, by far, is that Go won't let you import unused packages. When you are commenting stuff out to debug a program, or adding debug statements and removing them later, it constantly requires you to go back to the top of the file and comment out the unused libraries, only to uncomment them later when you've solved your problem. The fact that there is not a compiler flag to disable this be…

I use an Atom extension called "gofmt" which automatically calls goimports[1] every time I save. So any unused imports will be removed and if I start to use new imports that are in my GOPATH or the standard library then it automatically adds them. [1] https://godoc.org/golang.org/x/tools/cmd/goimports

How does that work with undo?

Re: I Love Go; I Hate Go

#52
post #10

The most frustrating thing for me, by far, is that Go won't let you import unused packages. When you are commenting stuff out to debug a program, or adding debug statements and removing them later, it constantly requires you to go back to the top of the file and comment out the unused libraries, only to uncomment them later when you've solved your problem. The fact that there is not a compiler flag to disable this be…

i was shocked by that at first too. Then I came to love it. It's sooooo go. Don't import stuff you aren't using. Don't declare a var and just leave it there un-used. When I go back to ruby and commit that crime, I see why golang did what it did. There's something magical about a golang program that will compile without error. It's worthy of checking in to git. And months later, there will be no unsed imports FOR SURE…

Why on earth would the language hinder you from iterating fast with a flag, and then convert all the warnings to errors when you run the full tests?

For example, most JS linters do that check and as a general rule, the build servers would reject the commit when the linter complains. I actually have a (very hacky) plugin to ESLint that automatically removes unused variables before `hg push`. It's totally not optimal, as in, you can still run/compile/transpile/whateverify the code with default options, but a language with no backwards compatibility worries can just add a flag to override strict checks to make a developers life easier, can't it?

I understand not implementing something that perhaps may not fit the language well or is so complicated that it really needs a lot of thought (read: generics). But this decision seems to be dogmatic at best.

I have the exact love/hate relationship with Go as the author of the article.

Re: I Love Go; I Hate Go

#54

Earlier quoted context omitted.

I use an Atom extension called "gofmt" which automatically calls goimports[1] every time I save. So any unused imports will be removed and if I start to use new imports that are in my GOPATH or the standard library then it automatically adds them. [1] https://godoc.org/golang.org/x/tools/cmd/goimports

How does that work with undo?

goimports guesses the one you want and adds it back.

Re: I Love Go; I Hate Go

#55
post #49

Oh. Go love-hate relationship post. My turn. So I really like channels and coroutines built into language and used everywhere: it makes some patterns compose nicely and language very productive. But just as in the article - some of Golang choices are opinionated and IMO just stupid. Lack of assertions is one: Sure programmers are prone to ignoring errors, but Go is not helping at all. Just bans assertions and provide…

> How do you decrement an atomic in Go?

Ooh. How do you delete from a slice in Go? With append() of course!

http://stackoverflow.com/questions/25025409/delete-element-i...

Re: I Love Go; I Hate Go

#57
post #54

Earlier quoted context omitted.

How does that work with undo?

goimports guesses the one you want and adds it back.

My question was, since goimports modifies your document (and gofmt even more so), is your undo stack preserved across saves? If so, how?

Re: I Love Go; I Hate Go

#59

Earlier quoted context omitted.

I use an Atom extension called "gofmt" which automatically calls goimports[1] every time I save. So any unused imports will be removed and if I start to use new imports that are in my GOPATH or the standard library then it automatically adds them. [1] https://godoc.org/golang.org/x/tools/cmd/goimports

How does that work with undo?

I can't speak for Atom, but here's what it's like in VIM: http://i.imgur.com/GkP4Yk9.gif

Re: I Love Go; I Hate Go

#60
post #54

Earlier quoted context omitted.

goimports guesses the one you want and adds it back.

My question was, since goimports modifies your document (and gofmt even more so), is your undo stack preserved across saves? If so, how?

That's a question for your text editor.

I use Sublime Text 3 with GoSublime and have noticed that the undo stack is just my changes (makes sense, the goimports is an external process), but that's cool because any CTRL+S is going to trigger goimports and so the correction of the imports is invisible and always there.

Post reply on HN