Go入门指南系列-XVIII-X-其他

如何在程序出错时终止程序:

1
2
3
4
if err != nil {
fmt.Printf("Program stopping with error %v", err)
os.Exit(1)
}

或者:

1
2
3
if err != nil { 
panic("ERROR occurred: " + err.Error())
}

链接