DEV Community

Cover image for Go Programming Language: Everything You Need To Know About It (Part 4)
Ganesh Kumar
Ganesh Kumar

Posted on

Go Programming Language: Everything You Need To Know About It (Part 4)

#go

Hello, I'm Ganesh. I'm working on FreeDevTools online, currently building a single platform for all development tools, cheat codes, and TL;DRs β€” a free, open-source hub where developers can quickly find and use tools without the hassle of searching the internet.

In my previous post, we got to know about how the go.mod file will help us to manage dependencies and manage minimum versions of Go to run this project, and we also learned about how a module is defined.

Now let's understand the standard library and function calling in Go.

Standard Library

We can import packages using the import keyword.

The standard library is a collection of packages that are already installed with the Go runtime.

we don't have to explicitly define it or install it.

import "fmt"
Enter fullscreen mode Exit fullscreen mode

fmt handles everything related strings.

Function Calling

Similar to other programming languages, we can call functions in Go.

This will be helping in gruoping related functions together.

func main(){
    fmt.Println("Hello, World!")
}
Enter fullscreen mode Exit fullscreen mode

main() is the function name.
Every excecutable are should have main function.

fmt.Println("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

We are calling Pritln function from fmt module.

This way we can able to use the functions defined under fmt.

Syntax Rules

Go is case sensitive and here are the rules for funtions calling.

fmt.Println("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

We can see Println where first letter is capital because it is to differentiate same module function calling differnt module function calling.

package main

import "fmt"

func main() {
    fmt.println("Hello, World!")
}
Enter fullscreen mode Exit fullscreen mode

If you are editing in IDE with go extention. It would already pointed error.

saying below error.

 go run main.go 
# command-line-arguments
./main.go:6:6: undefined: fmt.println
Enter fullscreen mode Exit fullscreen mode

In theoritical explaination the go exposing funtion from different module is from only this mechanism.

UTF-8 Encoding

All the previous coding languages are using ASCII encoding.

Which only consist of 128 characters.

But Go is using UTF-8 encoding.

Which consist of 1,114,112 characters.

Building executable

Building executable in go

gk@jarvis:~/exp/code/rd/go-exmaple$ go build main.go 
gk@jarvis:~/exp/code/rd/go-exmaple$ ./main 
Hello, World!
Enter fullscreen mode Exit fullscreen mode

By go build main.go go compiler compiled it and created executable file.

This is the basic cross compiled binary.

gk@jarvis:~/exp/code/rd/go-exmaple$ GOOS=windows GOARCH=amd64 go build main.go
gk@jarvis:~/exp/code/rd/go-exmaple$ ls
main  main.exe  main.go
Enter fullscreen mode Exit fullscreen mode

By above command we can able to build executable for windows.

Conclusion

We also learned about the standard library and function calling in Go.

Coming Next

Understanding the standard library and function calling in Go.


FreeDevTools

I’ve been building FreeDevTools for developers.

It is a curated collection of cheatsheets, Manual Pages, MCPs, SVGs, PNGs, and various frequently used tools crafted to simplify workflows and reduce friction.

My goal is to save you time by providing the materials you need for your daily work in one place, so you don't have to hunt across multiple websites.

It’s online, open-source, and ready for anyone to use. Any feedback or contributions are welcome!

πŸ‘‰ Check it out: FreeDevTools

⭐ Star it on GitHub: freedevtools

Top comments (0)