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("

Hello, World!

") }