Go常用库

flag

package main

import (
	"flag"
	"github.com/kataras/iris/v12"
)

// 需要配合 flag.Parse() 使用
var port = flag.String("port", "8080", "The address to listen on for HTTP requests.")

func main() {
	flag.Parse()
	app := iris.New()
	app.Get("/", index)
	app.Listen(":" + *port)
}

func index(ctx iris.Context) {
	ctx.HTML("<h1>Hello, World!</h1>")
}

原文地址:https://www.cnblogs.com/CSunShine/p/13355125.html