File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ module helloworld
2+
3+ go 1.20
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "os"
6+ )
7+
8+ // main is like any other programming language,
9+ // is the application's entry point.
10+ // Exactly 1 definition of this function is required in main package
11+ func main () {
12+ // check user has provided any
13+ // https://pkg.go.dev/os@go1.20.5#Args
14+ // https://pkg.go.dev/builtin#len
15+ if len (os .Args ) > 1 {
16+ // take the second element of the array and print hello to user
17+ // https://pkg.go.dev/fmt@go1.20.5#Printf
18+ fmt .Printf ("Hello, %s\n " , os .Args [1 ])
19+ } else {
20+ // if no argument is provided, print message with new line
21+ // https://pkg.go.dev/fmt@go1.20.5#Println
22+ fmt .Println ("Hello Guest" )
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments