GoLang Day 1: Getting Started

⌂ home      ⇧ one level up
Sun Jan 8, 2023 · 333 words · 2 min

Step 1 obviously is to install the thing. A simple pacman -Syu go was sufficient for me. i use arch btw

I hit the learn page. Nicest way to overwhelm me oof. Too many resources and didn't even tell me which one I should actually follow as a newb. Yes I can Google up blog posts and see how others did it, but coming from Rust, this felt kinda off putting. Rust has this book which explains everything nicely and is the goto for anyone starting with Rust, or even having to refer something while programming.

I'm just being impatient XD

I hit the Get started with Go page where I'm blessed with some starter material.

In a new folder, I could initialise a new module.

go mod init example/hello

and in a file hello.go, I paste some code

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Finally, go run . prints me Hello World. So I can safely assume I've entered the mad bad evil world and I gotta be fighting all sorts of bugs in the coming days.

Next thing the tutorial taught was to call an external package. So you go to Go Packages and search for a package you want to use.

Off topic - the search result page looked kinda basic and text heavy without much effort on the UI. Maybe something like the search result page of pub.dev could make things more welcoming.

So you put an import statement somewhere at beginning of your code like most languages and then you're free to call member functions.

package main

import "fmt"

import "rsc.io/quote"

func main() {
    fmt.Println(quote.Go())
}

You gotta run go mod tidy before you can actually run this code. My first honest reaction was that why would a "tidy" command be downloading modules. But maybe thats how Google wanted it?

Hopefully some heavy coding coming up in next post.


blog · about · resume · github · kde invent · endeavour · twitter · email · home

🚀❤️️🍰