[Go 공식문서 한국어 정리] Go의 에러 핸들링
[Go 공식문서 한국어 정리] Go의 에러 핸들링
원문 제목: Error handling and Go - The Go Programming Language
이 문서는 Go 공식 문서 중 'Go의 에러 핸들링'에 해당하는 원문입니다. 아래는 원문에서 다루는 주요 내용 일부입니다.
If you have written any Go code you have probably encountered the built-in error type. Go code uses error values to indicate an abnormal state. For example, the os.Open function returns a non-nil error value when it fails to open a file.
func Open(name string) (file *File, err error) The following code uses os.Open to open a file. If an error occurs it calls log.Fatal to print the error message and stop.
f, err := os.Open( filename.ext ) if err != nil { log.Fatal(err) } // do something with the open *File f You can get a lot done in Go knowing just this about the error type, but in this article we ll take a closer look at error and discuss some good practices for error handling in Go.
The error type is an interface type. An error variable represents any value that can describe itself as a string. Here is the interface s declaration:
자세한 내용은 위 출처 링크를 통해 원문을 확인하세요.
📎 출처 링크
https://go.dev/blog/error-handling-and-go
#Go #Golang #공식문서

오뉴노노 님의 최근 댓글
ㅋㅋㅋㅋㅋ 2019 01.14 잘 읽었습니다 2018 12.30 포인트가 없어서 아직 시작을 못하고있는데요! 글은 잘 읽었습니다! 포인트 쌓고 도전할거에요 2018 12.30