The Go Language (PART-2)



Go is a compiled language. The Go toolchain converts a source program and the things it depends on into instructions in the native machine language of a computer. These tools are accessed through a single command called go that has a number of subcommands.



We'll start with the traditional "hello, world" example.

package main

import "fmt"

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

The simplest of these subcommands is run, which compiles the source code from one or more source files whose names end in .go, links it with libraries, then runs the resulting executable file.

$ go run helloworld.go

If the program is more than a one-shot experiment, it’s likely that you would want to compile it once and save the compiled result for later use. That is done with go build:

$ go build helloworld.go

This creates an executable binary file called helloworld that can be run any time without further processing:

$ ./helloworld
Hello, World




17 views0 comments

Recent Posts

See All