Fundamentals 3 min read

Getting Started with Go: Essential Tips and First Hello World

This article shares practical Golang notes, covering compilation, package structure, basic syntax, common pitfalls like GOPATH issues, and step‑by‑step screenshots of setting up a Hello World program in Eclipse.

21CTO
21CTO
21CTO
Getting Started with Go: Essential Tips and First Hello World

The author shares initial Golang notes and a hands‑on tutorial.

Learning Go: some scattered notes from the early attempts.

Compilation and Execution

Compile and run: go run source.go Build and run:

go build source.go

Package and Imports

package main

defines an executable module.

Import required packages: import packagename Semicolons are unnecessary unless multiple statements appear on one line.

Functions

Define a function:

function functionname(){
//code
}

Command‑Line Arguments

Access arguments via os.Args or os.Args[0], where the first element is the program name.

First Hello World in Eclipse

Install the Goclipse plugin and create a simple program:

import (
"fmt"
)
func main(){
fmt.println("Hello World!")
}

The initial run produces an error (shown below):

Resolving GOPATH Issues

After moving the source to /src/main, a GOPATH‑related error appears:

Configure the project properties to add the project location to the required GOPATH:

Finally, the first program runs successfully:

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GolangprogrammingGoTutorialfundamentals
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.