0
Help us understand the problem. What are the problem?

posted at

【Golang】fmt.Errorfとerrors.Newの違い

変数を埋め込みたい時は fmt.Errorfを使う

err := fmt.Errorf("error create token: %w", err)

固定の文字列の時は errors.Newを使う

err := errors.New("invalid format")

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?