1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

エラー判定 (ファイルが見つかりません)

Posted at

判定コード

	data, err := ioutil.ReadFile(filePath)
	if err != nil {
		switch err.(type) {
		case *os.PathError:
			// ファイルが見つからない
		default:
			// その他のエラー
		}
	}

どのエラーが判定しているか確認するコード

t := reflect.TypeOf(err)
println("error: ", t.String())

実行結果

error:  *os.PathError
1
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?