You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit fixes invalid calls to i18n.Tr.
1. Missing positional arguments, for example:
return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s"), tool, err)
in the above case the positional arguments must be part of the Tr call:
- return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s"), tool, err)
+ return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s", tool, err))
2. This also makes the fmt.Errorf call useless and it could be replaced by
the less expensive errors.New:
- return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s", tool, err))
+ return errors.New(i18n.Tr("installing %[1]s tool: %[2]s", tool, err))
but we have cases of useless calls even when the string is a constant,
for example:
- err := fmt.Errorf(i18n.Tr("no instance specified"))
+ err := errors.New(i18n.Tr("no instance specified"))
Unfortunately, this imperfection is not detected by the linter.
3. The "%w" directive is not supported directly in i18n.Tr, so we have
to wrap it around another fmt.Errorf:
- return nil, fmt.Errorf(i18n.Tr("reading library headers: %w"), err)
+ return nil, fmt.Errorf("%s: %w", i18n.Tr("reading library headers"), err)
returnfmt.Errorf(i18n.Tr("Firmware encryption/signing requires all the following properties to be defined: %s", "build.keys.keychain, build.keys.sign_key, build.keys.encrypt_key"))
155
+
returnerrors.New(i18n.Tr("Firmware encryption/signing requires all the following properties to be defined: %s", "build.keys.keychain, build.keys.sign_key, build.keys.encrypt_key"))
0 commit comments