Answer the question
In order to leave comments, you need to log in
Why do I have only 1 element in os.Args?
I'm learning from a book by Donovan Kernighan.
when i execute the command
package main
import (
"fmt"
"os"
)
func main() {
var s, sep string
for _, arg := range os.Args[1:] {
s += sep + arg
sep = " "
}
fmt.Println(s)
}
Answer the question
In order to leave comments, you need to log in
Because go run compiles and runs. You don't specify additional parameters. Do go run main.go some args
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question