Naming, layout and comments: descriptive full-word names, one item per line in wrapped calls and literals, and doc comments on exported names

Short and single-letter names in application code become full words (tests
keep theirs). Wrapped calls, signatures and composite literals put one item
per line, and one-line function bodies are expanded. Exported names and
groups of constants get doc comments, and comments refer to the renamed
identifiers.
This commit is contained in:
bwilliams committed 2026-10-15 16:12:56 +01:00
1 parent 043e307663
commit 465358609a
78 files changed
+2374 -1402

No files matched your search

+11 -4
View File
@@ -63,8 +63,12 @@ func TestConfigShow(t *testing.T) {
cmdtest.Setup(t, appConfig)
out := mustRun(t, "config", "show")
cmdtest.Contains(t, out,
"logging.level = info <string>", "sources.sleeper.interval = 2m0s <string>")
cmdtest.Contains(
t,
out,
"logging.level = info <string>",
"sources.sleeper.interval = 2m0s <string>",
)
// Keys are listed in order, the same every time.
if again := mustRun(t, "config", "show"); again != out {
t.Errorf("config show output changed between runs:\n%s\n---\n%s", out, again)
@@ -158,8 +162,11 @@ func TestConfigSetUnset(t *testing.T) {
t.Errorf("config.yaml settings = %v; want %v", got, want)
}
// Back to the default.
cmdtest.Contains(t, mustRun(t, "config", "get", "sources.sleeper.interval"),
"10m0s <string>")
cmdtest.Contains(
t,
mustRun(t, "config", "get", "sources.sleeper.interval"),
"10m0s <string>",
)
}
func TestConfigSetWithoutConfigFile(t *testing.T) {
+3 -3
View File
@@ -32,12 +32,12 @@ func commandGet(opts *cli.Options) *cobra.Command {
return fmt.Errorf("no configuration loaded (%w)", err)
}
v, err := conf.ValueOf(args[0])
value, err := conf.ValueOf(args[0])
if err != nil {
return err
}
t, _ := conf.TypeOf(args[0])
fmt.Println(v, "<"+t.String()+">")
kind, _ := conf.TypeOf(args[0])
fmt.Println(value, "<"+kind.String()+">")
return nil
},
+2 -1
View File
@@ -74,7 +74,8 @@ func commandInit() *cobra.Command {
fmt.Print(
"writing default configuration to file: " +
viper.ConfigFileUsed() +
"\n")
"\n",
)
if err := viper.WriteConfig(); err != nil {
return err