Featured image of post Go Std Library

Go Std Library

Golang Tips and Tricks

All standard library of Golang can be accessed here pkg.go.dev/std.

os

Package os provides a platform-independent interface to operating system functinality.

os.Executable()

Returns the path name for the executable that started the current process.
Put this lines into file tryme.go

1
2
3
4
5
...
func main() {
	exec, _ := os.Executable()
	fmt.Println(exec)
}

And run go build . in the file dir. Then exec the output file ./tryme and you will see the terminal show your current file path like path/to/tryme

io

Package io provides basic interfaces to I/O primitives

net

Package net provides a portable interface for network I/O, including TCP/IP, UDP, domain name, resolution, and Unix domain sockets.

strings

Package strings implements simple function to manipulate UTF-8 encoded strings


References:

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy