go 主动退出进程
2021-03-11 tech go 1 mins 151 字

有时候简单调试应用,懒得写 go test,可以简单的使用 stdlib os 包,在main函数中直接退出应用程序。
package main
import (
	"fmt"
	"os"
)
func main() {
	fmt.Println("Hello World")
	// 正常退出
	os.Exit(0)
}

有时候简单调试应用,懒得写 go test,可以简单的使用 stdlib os 包,在main函数中直接退出应用程序。
package main
import (
	"fmt"
	"os"
)
func main() {
	fmt.Println("Hello World")
	// 正常退出
	os.Exit(0)
}