DEV Community

How I learned Go Programming

Francis Sunday on September 02, 2017

Go is a relatively new programming language, and nothing makes a developer go crazier than a new programming language, haha! As many new tech inv...
Collapse
 
bgadrian profile image
Adrian B.G.

Cool! I am learning Go too and I want to share with you guys my resources:

A playlist for newbies,take it as a crashcourse

I wrote a similar article, why I like Go last week

Collapse
 
tingtom profile image
Thomas

Thanks! Just started learning Go myself

Collapse
 
codehakase profile image
Francis Sunday

Thanks for sharing!!

Collapse
 
gcdcoder profile image
Gustavo Castillo

Hello Francis Sunday, I already have some experience in Go (I'm familiar with the syntax), I want to ask you what kind of projects did you build in order to become a better go developer?, I mean did you build APIs, Blogs, Just practice with the language?

Collapse
 
codehakase profile image
Francis Sunday

Whilst learning Go, I built a lot of things, from APIs (Here's an article I wrote on it hakaselabs.github.io/2017/06/23/re...), to little command line applications, currently I've been using Go extensively with the Company I'm with, and also Practice Practice!!

Collapse
 
codehakase profile image
Francis Sunday

You can always get in touch with me if you have any questions on Go, I'd be glad to help :)

Collapse
 
gcdcoder profile image
Gustavo Castillo

Thanks a lot I'm learning and practicing with Go all the time too, but I didn't have the chance of using it in a real project. Cheers!

Collapse
 
robdwaller profile image
Rob Waller

I've started to learn Go, however am struggling with interfaces, particularly compared to how they work in dynamically typed languages like PHP, any tips?

Collapse
 
codehakase profile image
Francis Sunday

Interfaces in OOP, enforce definition of some set of method in the class. By implementing interfaces, you are forcing any class to declaring some specific set of methods.

Interfaces in Go can be seen as named collections of method signatures.

For instance, a Geometry interface in go both Circles and Rectangles can implement the same Interface, but they must implement all the methods of that interface.

package main
import (
  "fmt"
  "math"
)

type geometry interface {
  area() float64
  perimeter() float64
}

type circle struct {
  radius float64
}

type rectangle struct {
  width, height float64
}

// implementing the interface methods

func (c circle) area() float64 {
    return math.Pi * c.radius * c.radius
}
func (c circle) perimeter() float64 {
    return 2 * math.Pi * c.radius
}

func (r rectangle) area() float64 {
  return r.width * r.height
}

func (r rectangle) perimeter() float64 {
  return 2*r.width + 2*r.height
}

// we can call methods that are in the named interface

func measure(g geometry) {
    fmt.Println(g)
    fmt.Println(g.area())
    fmt.Println(g.perimiter())
}

// The circle and rectangle struct types both implement the geometry
// interface so we can use instances of these structs as arguments 
// to measure

func main() {
  r := rect{width: 3, height: 4}
  c := circle{radius: 5}

  measure(r)
  measure(c)
}

Here's an awesome reference to learn more about Interfaces in Go jordanorelli.com/post/32665860244/...

Collapse
 
robdwaller profile image
Rob Waller

Thank you that is really useful.

Collapse
 
casperbraske profile image
Luis

It is said that Go doesn't have "generics" but these look pretty much like generics:

func (r rectangle) area()

func (c circle) area()

Thread Thread
 
baksman profile image
ibrahim Shehu

talking about user defined generics not built in๐Ÿ˜ƒ

Collapse
 
hooda profile image
Saurabh Hooda

That's a motivating post, Francis.
For the folks who wanna learn Golang, here are community recommended golang tutorials that can be good next step post this article: hackr.io/tutorials/learn-golang

Collapse
 
codehakase profile image
Francis Sunday

Thanks

Collapse
 
kellermanmota profile image
Kellerman

Hello Francis.

Great Article!!

I'm a Java Developer for some years, and I interested in Go for now.
I read in some articles that GO don't have a Virtual Machine behind and all the code is compiled to native code. This is true? If yes, which approach use to manage memory??

Thanks!!

Collapse
 
codehakase profile image
Francis Sunday

Hi there, take a look at this text from the Go website, it'll be of more help to answer your question - golang.org/doc/faq#garbage_collection

Collapse
 
serrevendedora profile image
Revendedora

Great Article!

Collapse
 
foresthoffman profile image
Forest Hoffman

Nice article Francis! Have any thoughts on testing with Go? I had to change the structure of my application in order to write proper tests (which turned out to be worth it). I'm curious to know how your shop does it.

Collapse
 
codehakase profile image
Francis Sunday

Thanks Hoffman, for testing, I use the testing package from the standard go library. In the nearest future I'd like to work on an easy testing framework, say something similar to Jasmine or mocha for Node.js

Collapse
 
itinsidenews profile image
itinsidenews • Edited

Awesome resource, Thank you for sharing. You may also like to check this website out

itinsidenews.com all-time best collection of android, ios and web development tutorials.

Collapse
 
muehan profile image
Andrรฉ

very good article. thanks!

Collapse
 
oparex profile image
Peter Opara

I see what you did there... not cool man, not cool at all, copying other peoples work. zemanta.github.io/

Collapse
 
codehakase profile image
Francis Sunday

Hey Peter, sorry if mine looks similar to yours, this was inspired by that article, I should have placed a credit though, skipped my mind. Anyways I'll make an edit to this.

Collapse
 
oparex profile image
Peter Opara

Hey Francis, please place a credit and link to Zemanta's tech blog in your post. Otherwise no worries, keep teaching others about Go!!
All the best in 2018!

Collapse
 
marvelousubani profile image
Marvellous Ubani

Have been looking to learn Go for a short while now. This is enough motivation for me too start off. Thanks Francis

Collapse
 
codehakase profile image
Francis Sunday

I'm glad this helped!

Collapse
 
johannesvollmer profile image
Johannes Vollmer • Edited

Cool. What do you think of nil?

resolve bad practices of others while keeping the good things.

I think optionals are safer than nil. What do you think?

Collapse
 
codehakase profile image
Francis Sunday

Well technically that may be true, but I prefer to stick with nil I often opt-in for optionals though.. but its preference over standards most times for me.

Collapse
 
codehakase profile image
Francis Sunday

Thanks again for another heads up :)

Collapse
 
carl_conton profile image
Carl Conton

Im stuck on css and dont even trying to finish it)

Collapse
 
codehakase profile image
Francis Sunday

Hilarious, remember if you're stuck somewhere, always ask someone, you'd get out of your problems in no time.

Collapse
 
johnsamuelob profile image
John Samuel Obinna

Wow! Awesome. I will give Go a try.

Collapse
 
codehakase profile image
Francis Sunday

Sure, you're gonna love it

Collapse
 
zhikiri profile image
Zhivitsa Kirill

Hey, thanks for great post. I've just found some bugs in first example, you can check my version here play.golang.org/p/D1V6irVthg

Collapse
 
tutlane profile image
Tutlane

Good one. Thanks I started learning Go and will share it in my Tutlane tutorials section.

Collapse
 
titaniumals profile image
Almas

Awesome resource Francis, thanks for sharing. You may also like to check this resource out coursesity.com/best-tutorials-lear... . Some of the best-curated collections of all time

Collapse
 
codehakase profile image
Francis Sunday

I'm glad it was helpful Jacinto!!

Collapse
 
codehakase profile image
Francis Sunday

Thanks for the hint, I'll update that ASAP

Collapse
 
letsfindcourse profile image
letsfindcourse

Nice article, people who want to learn golang can check the best go tutorials recommended by experts at letsfindcourse.com/golang