Skip to content
Snippets Groups Projects
Commit db278dd6 authored by Martin Schmollinger's avatar Martin Schmollinger
Browse files

Solution to exercise of unit 02-05

parent 79bd26a2
No related branches found
No related tags found
No related merge requests found
module gitlab.reutlingen-university.de/go-exercises/go-starter/exercise_0205
go 1.20
package main
import (
"fmt"
"os"
)
func printSlice(s []string) {
fmt.Printf("%p –len: %d cap: %d %#v\n", s, len(s), cap(s), s)
}
/*
func main() {
if len(os.Args) > 1 {
printSlice(os.Args)
} else {
fmt.Printf("Usage: %s <sentence>\n", os.Args[0])
}
}
*/
func main() {
noOfArgs := len(os.Args)
switch noOfArgs {
case 1:
fmt.Printf("Usage: %s <sentence>\n", os.Args[0])
default:
printSlice(os.Args)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment