# First Program

## Classic Hello World Program in Go

Okay, so we are all set up with Go. Now let's create our hands dirty and create a trivial Hello World program. Let's create a file and it `hello.go`

```go
package main
import "fmt"
func main() {
    fmt.Println("Hello World")
}
```

That's it. We are done with our program and now save it in a file named `hello.go` Now Go provides us to compile and run the program in a single command. Fire up the terminal, head in a folder where we saved `hello.go` and run

{% hint style="info" %}
Note: For example code shown here refers to go environment in Ubuntu 18.04. Illustration may change a bit depending upon OS being used
{% endhint %}

```bash
go run hello.go
# => Hello World
```

This should output the > Hello World string. Go also provides us a way to compile this program into executables by using `go build`

```bash
go build hello.go
# => This should create an executable in same directory
# => hello  hello.go
```

Is `hello` is an executable generated by `go build`. This can be run in terminal

```bash
./hello
# => Hello World
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://golang.bagwanpankaj.com/first-program.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
