DEV Community

My 2 Cents On Go

Ido Shamun on October 22, 2018

Following my post, I decided to take on an action and learn Go. Should I learn Go? Ido Shamun ใƒป Sep ...
Collapse
 
bgadrian profile image
Adrian B.G.

Imperative programming (just a personal opinion)

All languages are imperative now days, I think you wanted to say Procedural Programming?

I personally love procedural programming, I think Go is the perfect mix between a FP and OOP style. You have a bit of everything to solve problems "good enough" in small/medium projects.

Collapse
 
eljayadobe profile image
Eljay-Adobe

"...Go is the perfect mix between a FP and OOP style."

You're killin' me, Smalls!

Collapse
 
bgadrian profile image
Adrian B.G.

I have no idea what you said, but I will put the accent on "I", as in "for me" :))

I can apply patterns from both world, but of course, does not excel at either of them.

Collapse
 
idoshamun profile image
Ido Shamun

PP is a type of imperative programming. I love FP which is obviously a type of declarative programming.
The code looks much more elegant and clean, sometimes it can be harder to read though.

Collapse
 
arschles profile image
Aaron Schlesinger

I love this writeup - really succinct and accurate, IMO (I've been writing Go almost exclusively for 5+ years)

I felt like the GOPATH and the dependency management tools were always a thorn in my side. Recently, they started turning me off of Go TBH, but 1.11 fixed both (others have more detail). And shameless plug: I'm working on a server for Go modules so that you don't have to pull code directly from GitHub if you don't want to - because that's caused problems in the past too.

github.com/gomods/athens

Collapse
 
quii profile image
Chris James

To mock functions declare them as variables

Do you mean having them as global variables? If so, please dont do this.

Use dependency injection for explicit documentation of what your code is using and where.

Collapse
 
idoshamun profile image
Ido Shamun

For a small scale service I find it cumbersome but you are right DI is the better way

Collapse
 
rhymes profile image
rhymes

Dep (dependency manager) is not as trivial as NPM
GOPATH!? Why is everything has to be in the same directory?

I hated this, fortunately with go modules is mostly solved

Collapse
 
bgadrian profile image
Adrian B.G.

I am using Go modules and it works good so far.

Collapse
 
idoshamun profile image
Ido Shamun

Unfortunately I haven't heard about go modules, I'll give it a go

Collapse
 
rhymes profile image
rhymes

ahha don't worry, they are a super recent thing. They have been added in Go 1.11

Collapse
 
mustardsauce profile image
Jakub N

Being new to golang, my biggest concern is, how do I organize/structure my code. Flat structure for simple application I am currently building seems reasonable, but it still seems weird for me.

Collapse
 
idoshamun profile image
Ido Shamun

I can totally relate to this one! It annoys me as well, not sure how to structure the project

Collapse
 
mustardsauce profile image
Jakub N

I really like the approach suggested in this article: medium.com/@benbjohnson/standard-p..., but don't want to overcomplicate the whole thing.

Collapse
 
theredspy15 profile image
Hunter Drum

In my opinion, the GOPATH is the only con to Go. But it is a VERY annoying one

Collapse
 
stephenafamo profile image
Stephen Afam-Osemene

2/4 of your cons are fixed with Go 1.11 which was released late August.

The GOPATH thing and dependency management.
So simple you don't even have to think about it.

Collapse
 
idoshamun profile image
Ido Shamun

That's great to hear!
I am sure the language will evolve and become much better as long as a tech giant as Google backs it

Collapse
 
david_j_eddy profile image
David J Eddy

Your 'Cons' are my thoughts exactly! The requirement for GOPATH still confused me as to why it is that way. As for the error handling, that should get better with the recent release.