/gpg/ - Go Programming General

Talk about everything Go!

It's not possible to make a thread about everything Go.
You need to reimplement the thread for every topic separately.

What are some good books/ videos that have me do a project/application in Golang? I'm learning it right now as my first language and want something to work on after.

*silently returns nil*
nothing personnel

Kek

There is an official, interactive tutorial online with a sandbox.

How would you fix this Go design pattern:
foo, err := bar();
if err != nil {
...
}

I don't really understand the rationale behind using casing to determine what is exported in a package. It might make sense to use casing to distinguish between two things which are both available in the public API, but because the client always uses foo.Bar, you're not getting any extra information. Idk. I could probably be won over since it's such a minor issue.

Do what Swift does and add some sugar for it.

I used to hate this language (and still do desu), but since I started maintaining one monstrous PHP project I'm now pushing for Go, if only to limit the amount of damage these fucking retards can cause (they can't complain it's too hard since it was designed for brainlets).

Now those people jumped to NodeJS after PHP and proceed to do the exact same shit as before, thinking it's an improvement. I hope Go and other better compiled languages finally kill all these scripting languages for backend development.

What do you dislike about Go

I basically have the same opinion. I'm pretty neutral towards the language itself, but I've found that Go is pretty good for team projects where the ability of team members is all over the place.
We're starting to use it at work and it's increased productivity and people are generally happy with it.

Off the top of my head?
* no null safety
* using product types for error handling
* multiple return but no tuples
* no FUCKING immutable variables
* structural subtyping
* no generics (given)
* interface{} and downcasting everywhere
* no assertions
* unused modules and other minor bullshit are compile errors instead of warnings
* no macros
* delusional community

How do you prefer errors be handled? I'm not some big fan of Go. I'm just curious

Fuck your botnet meme language.

I honestly don't understand why this should be "fixed".
Ignoring you errors is dumb. Doing it in a monadic fashion is more sugar than a real advantage, and go isn't a very 'sweet' language, so I hope it stays this way.

Monads are a lot more than just sugar.

I understand (since I am a Haskell programmer too).
Adding Monads to go is unfeasible without changing the whole language, so people have been saying to add some form of monadic error handling (basically sugar).
I think this is issue is blown out of proportion.
There is nothing wrong with checking for errors this way in a procedural language.
It's better than try/catch. It's better than the C way. It's simple and effective.

Go brainlets are so terminally retarded, they don't understand what is int[]

>tfw too intelligent for postfix notation

With Haskell-like monads the language semantically enforce proper "error" handling. Go will never do something like this.

What makes monadic error handling "proper"?

They finally added a round function to the standard library after 10 years. What amazing progress!

>int[]
is an array of ints

Bump

Sum types / monadic error handling a la Option. This way you can have destructuring, automatic conversions of ErrorA into ErrorB, handling actual error messages in one place instead of sprawling through your codebase.

>handling errors in one place
That promotes bad generic error handling where you just print out an error message and die for every error.

Agreed

>promotes
Just don't be a retard and you won't need a language with features purposefully taken out to prevent you from hurting yourself.

It might not matter for a neet like yourself but the reality of software development is that you're working with a lot of other people's code. And most of them are morons. A language that it makes harder to write shitty code is beneficial to everyone.

I'm pretty sure that type system enforced error handling beats "someone might put the code in the wrong place" if you are dealing with morons.

As evidenced by Java?

Google is evil and you guys are supporting it.

Obviously not because the most common exceptions are unchecked exceptions and the standard library doesn't use Optional