Skip to content

Instantly share code, notes, and snippets.

@dacr
Created March 28, 2025 09:01
Show Gist options
  • Save dacr/b8115e0cec3f655cef85e36f27147780 to your computer and use it in GitHub Desktop.
Save dacr/b8115e0cec3f655cef85e36f27147780 to your computer and use it in GitHub Desktop.
go hello world script with arguments / published by https://github.com/dacr/code-examples-manager #87072695-36c8-4a30-83e6-83304ca0dd7e/a5490099dc803489c94bfa5e39bbabce3aed8653
/*?sr/bin/true; exec /usr/bin/env nix-shell -p go --run "go run $0 $@" #*/
// summary : go hello world script with arguments
// keywords : go, hello-world, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 87072695-36c8-4a30-83e6-83304ca0dd7e
// created-on : 2025-03-06T15:29:14+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : nix-shell -p go --run "go run $file joe"
package main
// TODO the shebang is not running fine with more than 1 argument !
import (
"fmt"
"os"
)
func main() {
args := os.Args[1:]
for _, arg := range args {
fmt.Printf("Hello %s\n", arg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment