1. Use github.com/lxn/walkto package a desktop program. Then, the IP address will be displayed on the application program. (small programs can work together to prevent them from being used)
2. Add go build-ldflags = "-H windowsgui" during cmd compilation"
3. github.com/lxn/walk. during compilation, the file rsrc.sysoand. mainfest must be used in the same directory as the package.
Package mainimport ("fmt" "log" "net" "strings") import ("github.com/lxn/walk ". "github.com/lxn/#/declarative") func main () {var te * walk. textEditif _, err: = (MainWindow {Title: "Test", MinSize: Size {300,200}, Layout: VBox {}, Children: [] Widget {TextEdit {AssignTo: & te ,}, PushButton {Text: "LocalAddr", OnClicked: func () {text: = GetAddr () te. setText (text )},},},}). run (); err! = Nil {log. fatal (err)} func GetAddr () string {// Get ipconn, err: = net. dial ("udp", "baidu.com: 80") if err! = Nil {fmt. println (err. error () return "Erorr"} defer conn. close () return strings. split (conn. localAddr (). string (), ":") [0]}
This article to the Source world http://www.ymsky.net/views/73305.shtml