
How I Start: Go (2014) - ianrtracey
http://howistart.org/posts/go/1/
======
thewhitetulip
I agree that Go makes programming simple, in a matter of less than 6months, I
learned how to write a webapp in Go just by using the standard library, later,
I wrote a guide to teach how to write webapps in Go without using a framework,
using an example based approach

[https://github.com/thewhitetulip/web-dev-golang-anti-
textboo...](https://github.com/thewhitetulip/web-dev-golang-anti-textbook/)

~~~
2_listerine_pls
6 months? that's a lot of time.

~~~
thewhitetulip
It isn't if you add learning web dev from scratch. I had never ever worked
with webdev before

~~~
chickenfries
So then you have nothing to compare it to, and you can't say that Go made
things simpler or faster than if you had started making web apps in say,
python.

~~~
thewhitetulip
I had tried my hand with Django and flask, just read the tutorials, and for
6-7 months, I was still reading tutorials, and every 6 months a new version of
framework would come up, and I'd be upgrading stuff. I would write views
without understanding what they really mean.

Maybe I learned Python webdev in a wrong way, so, compared to that, Gonwas a
cakewalk.

~~~
chickenfries
So you don't think the background knowledge you gained about web dev in 6-7
months of studying python helped you pick it up faster in Go?

> for 6-7 months, I was still reading tutorials, and every 6 months a new
> version of framework would come up

So, according to you, the invention of ONE new python framework caused you to
rewrite everything you had been working on? What frameworks did you switch
between? Why?

Golang is a popular language now, and there are going to be frameworks coming
out all the time. There are already lots of Golang webdev frameworks. Imagine
if you were starting with Go now, and you learned something like Revel
([https://revel.github.io/](https://revel.github.io/)) before learning how to
make web apps with the standard library. Or imagine you spent 6 months
learning a framework and then decided to jump to a new one when another one
came out.

Also, from perusing the introduction to your Golang book, it seems like you
were lacking knowledge of HTTP and other standards. I find that it's very
difficult for anyone to learn web development without at least understanding a
little bit about HTTP first. Only once you understand how all web development
is the same, can you evaluate the ways that different languages do the job of
writing HTTP servers.

~~~
thewhitetulip
>So you don't think the background knowledge you gained about web dev in 6-7
months of studying python helped you pick it up faster in Go?

No, the thing is, while I was studying Django, I wasn't learning how to write
webapps, I was learning the framework. As I said earlier, I might have gone in
the wrong way to learn. I didn't find a book which taught me what I wanted to
learn, they all either were too abstract or taught a framework, thus, I
started to write my guide, which assumes no background knowledge.

> the invention of ONE new python framework

Did I say that?

>Imagine if you were starting with Go now, and you learned something like
Revel

The whole point behind my tutorial was to teach newcomers how to write webapps
without using a framework.

> Also, from perusing the introduction to your Golang book, it seems like you
> were lacking knowledge of HTTP and other standards

I don't claim to know each and every aspect of HTTP and other standards, my
book was about the journey I had while learning webdev and Go without using a
framework, everyday there are new programmers trying to write webservers in
Go, and I felt that there was a need of a book which taught by example.

> Only once you understand how all web development is the same, can you
> evaluate the ways that different languages do the job of writing HTTP
> servers.

True, with Go, it was no hassle to write webapps because Go has built in http
library and it is a compiled language, thus my shift from Django to Go.

~~~
chickenfries
> Did I say that?

No, not exactly, but you complained that "for 6-7 months, I was still reading
tutorials, and every 6 months a new version of framework would come up," can
you explain what you meant by this? You say you were learning Django, why did
you not stick with that? What new frameworks came out that made you stop
learning Django?

> True, with Go, it was no hassle to write webapps because Go has built in
> http library and it is a compiled language, thus my shift from Django to Go.

See, these are the kind of statements I take issue with. interpreted languages
are incredibly popular in web development because of how much easier they are
to get started with than compiled languages. Not that I think AOT compilation
makes a language bad for web development, but you seem to be asserting that Go
is better for web dev and easier to learn because it is compiled and has a
built in http library (python has one too!
([https://docs.python.org/2/library/httplib.html](https://docs.python.org/2/library/httplib.html))
and if it's too low level for you, the documentation even points you to the
open source requests library, which is the standard in the python community).

> As I said earlier, I might have gone in the wrong way to learn.

Yes, this is the point I'm trying to make. You're comparing apples to oranges
when you say that Go makes web development easy to pick up compared to Python
when you didn't really try to learn web development in Python, you tried to
learn a high level framework without knowing anything about HTTP, a recipe for
disaster in Python OR Golang (the point I was trying to make by referencing
Revel).

------
baby
1\. setting GOPATH as $HOME made me uncomfortable, I don't see why anyone
would want to pollute his/her home directory with bin, pkg, and src folders.

2\. in his example, `go get github.com/your-username/hello` also automatically
compile the thing into a binary in `$GOPATH/bin`. Is that correct?

~~~
didip
I don't think GOPATH as $HOME is a common thing (even back then).

A lot more people uses $HOME/go as GOPATH. So much so that $HOME/go is the
default in Go 1.8.

------
zerr
Aren't people annoyed by URL imports? e.g.:

import
"[http://www.geocities.com/bla/packagebla"](http://www.geocities.com/bla/packagebla")

i.e. I don't want to mention some 3rd party irrelevant company name, and
especially its URL in my source code.

~~~
gtrubetskoy
So, why not:

    
    
      mkdir $GOPATH/src/mystuff
    
      git clone https://github.com/foo/bar 
      # may be switch to a branch here while you're at it
    
      mv bar $GOPATH/src/mystuff/bar
    

Now in your Go program

    
    
      import "mystuff/bar"
    

The whole "URL import" is not a "feature of Go", it's an artifact of "go get",
just a tool to make it easier to pull code from github or whatever.

~~~
hazbo
If package `github.com/foo/bar` imports a nested package, say,
`github.com/foo/bar/baz`, this will break as it will be trying to look for
said package in `$GOPATH/src/github.com/foo/bar/baz`.

------
petepete
So I can't just put my code in ~/Projects like with every other programming
language I've ever used?

~~~
tscs37
Create the folder ~/Projects/go and use it as gopath, I recommend a vendoring
tool to prevent cluttering.

~~~
matthewmacleod
This is what I've ended up doing, and it still drives me absolutely batty.
Typically I'd group together all of the code and assets for a project in one
place; any Go code has to exist in this separate namespace for no convincing
reason.

It's fine, I can work around it, but it's still quite annoying.

~~~
hazbo
Something I pretty much do and have heard from other Go people that they do
this also, is to just keep all my projects in the GOPATH. Whether they be
written in Go or not. It essentially gives you an organised structure based on
git URLs, so it's always easy to find anything. I use $HOME/go, and have
projects in there written in a bunch of languages.

~~~
woah
I do this. It's actually a pretty good way to organize code in general, not
just Go. Still dumb that they force it on you.

------
tedchs
I absolutely love Howistart, but some of their tutorials are getting a little
dated. This one uses Go 1.3, whereas 1.8 is now GA, and there has been a lot
of progress around vendorizing dependencies.

~~~
startupdiscuss
For those of us who are new to go, can you say a little more about how this
might be different if it was updated for 2017? (Or if it is involved, perhaps
a link?)

~~~
sagichmal
There would be no substantial changes, as this project has little to no
interaction with the GOPATH, and doesn't use any dependencies. It's a
testament to the stability of the language.

------
tachion
Interestingly, the very first thing I've read, that is the environment setup
contains instructions that I was told are incorrect by Golang people - one
should not use brew to install Golang on macs, one should download the
official package. The brew installation, for example, lacks the offline tour
package, and who knows what else.

~~~
fnord123
The brew formula is here:

[https://github.com/Homebrew/homebrew-
core/blob/master/Formul...](https://github.com/Homebrew/homebrew-
core/blob/master/Formula/go.rb)

    
    
        url "https://storage.googleapis.com/golang/go1.8.src.tar.gz"
        mirror "https://fossies.org/linux/misc/go1.8.src.tar.gz"
        version "1.8"
        sha256 "406865f587b44be7092f206d73fc1de252600b79b3cacc587b74b5ef5c623596"
    

This checksum matches the one on the official download page:

[https://golang.org/dl/](https://golang.org/dl/)

406865f587b44be7092f206d73fc1de252600b79b3cacc587b74b5ef5c623596

The Golang people could save a lot of headaches and fix whatever they see
wrong in the formula so people can continue to use their package manager
instead of being reduced to Windows style savagery.

Edit: looks like someone indeed tried to make an issue:

[https://github.com/Homebrew/homebrew-
core/issues/9272](https://github.com/Homebrew/homebrew-core/issues/9272)

If I understand, the Go team made the binary package install stuff not in the
source tarball. That's doesn't sound like a good idea but they're some smart
people; I'm sure they have some reasons. T'woud be nice if they helped bring
brew in-line as well.

------
grennis
After seeing URL string parsing in application code I would have expected to
see at least some sort of discussion about third-party web frameworks.

~~~
viiralvx
Even a web framework isn't necessary. Most people get around that nastiness
using gorilla/mux:
[https://github.com/gorilla/mux](https://github.com/gorilla/mux)

------
thekingofh
Has anyone noticed an extreme explosion in languages? It seems like a good
hobby project to create your own language and then evangelize evangelize
evangelize.

I'm all for advancement, but this feels like overload. We have each of the big
companies promoting their own languages. Microsoft: C# (and other flavors),
Apple: Swift, Google: Go, Mozilla: Rust... I'm sure I could keep going, but
that seems to be the trend lately. You can't be a big company and not have
your own programming language.

So I guess the language changes for each domain. There is no longer the dream
of a single language to unite all the plebes! Maybe it was a dream anyways.

~~~
insertnickname
I'm all for advancement, but this feels like overload. We have each of the big
companies promoting their own languages. Microsoft: Visual Basic, Apple/NeXT:
Objective-C, Bell Labs: C and C++, Sun: Java... I'm sure I could keep going,
but that seems to be the trend lately. You can't be a big company and not have
your own programming language.

By the way, C# has been around for 17 years.

~~~
thekingofh
True. And it's a beautiful language. I'm not necessarily knocking the other
languages either. It's just that it seems that the fragmentation is becoming
an issue, when all that development effort doesn't seem to necessarily be
generating more value. I'm sure it's possible by all of this experimentation
someone will stumble upon the next Javascript, or the next C. So there may be
a benefit in the long run. Or maybe not.

------
k2xl
It is really great that the latest Go version doesn't require setting the
GOPATH

------
nowbacktowork
Reading the title I was really hoping this was story of a program loading and
executing. And that the site had this documented for multiple languages.

Does anyone know of a resource like that? I understand it would be different
in on each platform but a fun and interesting read either way.

------
alimbada
It's 2017 and developers are still abbreviating variable names ('err', 'resp',
etc. in the article). It's tragic that readability is still not seen as a
priority by so many people.

~~~
fiatjaf
'error' is a protected keyword in Go.

~~~
alimbada
Then use another word; 'defect' and 'fault' are two acceptable synonyms I
managed to look up in less than a minute.

~~~
hazbo
Given that errors and error handling itself is a very normal thing to come
across in most projects, would the abbreviated `err` not seem more familiar
than defect or fault, to you?

------
okket
(2014)

see Github project [https://github.com/peterbourgon/how-i-start-
go](https://github.com/peterbourgon/how-i-start-go)

and Twitter
[https://twitter.com/How_I_Start/status/506510262909030400](https://twitter.com/How_I_Start/status/506510262909030400)

