lean into examples
This commit is contained in:
9
examples/hello-world/hello-world.go
Normal file
9
examples/hello-world/hello-world.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Our first program will print the classic "Hello world"`
|
||||
// message. Here's the full source code.
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello world")
|
||||
}
|
||||
17
examples/hello-world/hello-world.sh
Normal file
17
examples/hello-world/hello-world.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
# To run the program, put the code in `hello-world.go` and
|
||||
# use `go run`.
|
||||
$ go run hello-world.go
|
||||
Hello world
|
||||
|
||||
# Sometimes we'll want to build our programs into
|
||||
# binaries. We can do this using `go build`.
|
||||
$ go build hello-world.go
|
||||
$ ls
|
||||
hello-world hello-world.go
|
||||
|
||||
# We can then execute the built binaries directly.
|
||||
$ ./hello-world
|
||||
Hello world
|
||||
|
||||
# Now that we can run and build basic Go programs, let's
|
||||
# learn more about the language.
|
||||
Reference in New Issue
Block a user