Answers for "golang passing parameter to the program"

Go
0

golang passing parameter to the program

package main
import (
    "fmt"
    "os"
)
func main() {

    argsWithProg := os.Args
    argsWithoutProg := os.Args[1:]
You can get individual args with normal indexing.

    arg := os.Args[3]
    fmt.Println(argsWithProg)
    fmt.Println(argsWithoutProg)
    fmt.Println(arg)
}
Posted by: Guest on August-10-2021

Code answers related to "golang passing parameter to the program"

Browse Popular Code Answers by Language