ParseInLocation is like Parse but differs in two important ways.
First, in the absence of time zone information, Parse interprets a time as UTC;
ParseInLocation interprets the time as in the given location.
Second, when given a zone offset or abbreviation, Parse tries to match it against the Local location;
ParseInLocation uses the given location.
ParseInLocation と Parse の違い
文字列に location の情報がない場合、 Parse は UTC として扱う
zone offset が指定された場合、 Parse は Local location からの offset として扱う
funccreateUser(name string, age int)error{ if err :=checkName(name); err !=nil{ return errlog.Wrap(err, logrus.Fields{"age": age},"failed to create a user") } }
つまり上のコードでは子関数に渡っているメタ情報nameや、invalid username のようなメッセージを errlog.Wrap に渡す必要はありません。
上記の例だとエラーに関係ない age も渡す必要はないのではないかとも考えられますが、原則ログに残すこととします。
if f, err := os.Open(filename); err !=nil{ return errlog.Wrap(err, logrus.Fields{"filename": filename},"failed to open a file","failed to create a user") }
上記の例だと、os.Openに渡したメタ情報 filename や os.Openに失敗したことを示す failed to open a file といったメッセージもerrlog.Wrapに渡しています。