DEV Community

Joseph utuedeye
Joseph utuedeye

Posted on

🚀 Developing with Golang: A Beginner's First Steps

By a beginner, for beginners.

Go for beginners

When I first started learning Go (Golang), everything felt a little strange. Coming from the Python and JavaScript background😅😅., I expected to deal with new syntax, but I didn’t expect to get stuck on the very first line of every Go file:
package main

I remember asking myself:
"Why do we declare the package name before the start of any code?"
Well, let’s break it down and walk through the basics of developing with Go.

📦 What Is a Package in Go?

In Go, as well as other languages like Python, a package is a way to organize and reuse code. Every .go file must start by declaring which package it belongs to.

There are two kinds of packages you’ll encounter early on:

  • main: This package is special. It tells the Go compiler that this file is part of an executable program.
  • Library packages: These are packages meant to be imported into other Go files. For example, a helper package might look like: package utils

If you're writing a standalone program that you want to run, you’ll always use:
package main

🧪 Let’s Build a Simple Go Program
Here’s a small Go program to illustrate everything:

package main

import "fmt"

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

Enter fullscreen mode Exit fullscreen mode

🔍 What’s Happening Here?

  • package main: Declares this file as part of the main executable.
  • import "fmt": Pulls in Go’s formatting package, used to print things.
  • func main(): The entry point of any Go executable program.
  • fmt.Println(...): Prints a line of text to the terminal.

Try running this with:
go run hello.go

🤔 Why Is Go So Strict?
Go may feel strict at first, but this is intentional.
It enforces clear, consistent, and minimal syntax. That’s part of what makes it easy to read, even in large codebases. Once you adjust, you’ll appreciate how little guesswork there is.

💡 Tips for New Go Developers

  • Always declare your package; it is required.
  • Use go run file.go to run a single file quickly.
  • Go has an amazing standard library: explore net/http, os, strings, etc.
  • Use Go by Example to see real-world code snippets.

Don’t be afraid of the unfamiliar; it gets easier, fast!

🛠️ Final Thoughts

Go is a language that values simplicity, and that starts right from line 1 with package main. While it might feel odd at first, it’s one of the reasons Go is so approachable for building everything from scripts to scalable backend systems.
If you’re just starting your Go journey, remember this:
You don’t need to know everything at once; just keep going.
Write code, break things, and ask questions (like I did about package main).

You're on the right path. Happy coding! 🧑‍💻

Got questions or want to share your first Go project? Drop them in the comments, I’d love to connect!

Top comments (2)

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

Haha I totally got tripped up by that first "package main" too when I tried Go for the first time. The adjustment hits harder than you think, but man, it really grows on you after a few days.

Collapse
 
joe_ profile image
Joseph utuedeye

Yeah 😅😅 . It later become part of you