7 ms·
Hey there I found modules to be confusing coming from GOPATH too, but they're straight forward, super barebones example: #!/bin/bash cd $HOME # C
by triztian 6y ago
Hey there I found modules to be confusing coming from GOPATH too, but they're straight forward, super barebones example:
#!/bin/bash
cd $HOME
# Create project directory
mkdir hellogo
cd hellogo
# Init project modfile
go mod init example.com/hellogo
# Create the main source file
# Uses bash's heredoc
cat << EOF > ./main.go
package main
import "fmt"
func main() {
fmt.Print("Hello world")
}
EOF
# Build it
go build
# Run it
./hellogo
- sk0g 6y agoYou can also skip building, and run directly using `go run`!