Skip to content

Instantly share code, notes, and snippets.

@oscarzhou
Created June 12, 2021 01:15
Show Gist options
  • Save oscarzhou/a4d68c8cab318d3b8470d98903473cfb to your computer and use it in GitHub Desktop.
Save oscarzhou/a4d68c8cab318d3b8470d98903473cfb to your computer and use it in GitHub Desktop.

Revisions

  1. oscarzhou created this gist Jun 12, 2021.
    15 changes: 15 additions & 0 deletions parse-flag-with-builtin-type.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    package main

    import (
    "flag"
    "fmt"
    )

    func main() {
    var version string

    flag.StringVar(&version, "setVersion", "1.0.0", "") // parse the value of the flag setVersion to variable version
    flag.Parse()

    fmt.Println("version = ", version)
    }