タグ

ブックマーク / qiita.com/umisama (1)

  • os.Exit()とdefer - Qiita

    golangのos packageにはExit()という関数がいて、その名の通りOSに値を返してプロセスが死ねる。 で、ドキュメントによると、 func Exit(code int) Exit causes the current program to exit with the given status code. Conventionally, code zero indicates success, non-zero an error. The program terminates immediately; deferred functions are not run. とあって、deferに登録した関数をすべて破棄してくれるらしいと書いてある。念の為に試しておくと、 package main import "os" func test() { println("hello in t

    os.Exit()とdefer - Qiita
  • 1