giplib: separate functions in lib and app
Signed-off-by: Nagy Károly Gábriel <k@jpi.io>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.jpi.io/karasz/gip/giplib"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
//Version contains the git hashtag injected by make
|
||||
Version = "N/A"
|
||||
//BuildTime contains the build timestamp injected by make
|
||||
BuildTime = "N/A"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var all bool
|
||||
ptr4 := flag.Bool("4", false, "return only IPv4")
|
||||
ptr6 := flag.Bool("6", false, "return only IPv6")
|
||||
version := flag.Bool("v", false, "return version")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *version {
|
||||
fmt.Println(Version, " built on ", BuildTime)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *ptr4 == *ptr6 {
|
||||
all = true
|
||||
}
|
||||
if all {
|
||||
fmt.Println(giplib.GetIPv4())
|
||||
fmt.Println(giplib.GetIPv6())
|
||||
os.Exit(0)
|
||||
}
|
||||
if *ptr4 {
|
||||
fmt.Println(giplib.GetIPv4())
|
||||
}
|
||||
if *ptr6 {
|
||||
fmt.Println(giplib.GetIPv6())
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user