From 6a2470db54b8c1024dfc756d16678e4d362d4a68 Mon Sep 17 00:00:00 2001 From: surtur Date: Fri, 27 May 2022 22:14:29 +0200 Subject: [PATCH] fix: implement godot's suggestions on app comments --- cmd/root.go | 10 +++++----- cmd/root_test.go | 2 +- cmd/version.go | 10 +++++----- cmd/version_test.go | 4 ++-- xkcdreader/about.go | 2 +- xkcdreader/app.go | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 2bd0096..040ce68 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,10 +10,10 @@ import ( "github.com/spf13/cobra" ) -// appName is the name of the app +// appName is the name of the app. const appName = "go-xkcdreader" -// Root is the main go-xkcdreader command +// Root is the main go-xkcdreader command. var Root = &cobra.Command{ Use: appName, Short: "an offline-capable xkcd webcomic reader written in Go", @@ -24,12 +24,12 @@ var Root = &cobra.Command{ }, } -// GetAppName returns the name of the application +// GetAppName returns the name of the application. func GetAppName() string { return appName } -// Execute is the entrypoint of cobra's poison +// Execute is the entrypoint of cobra's poison. func Execute() { if err := Root.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) @@ -38,7 +38,7 @@ func Execute() { } // help redefines the original help func, essentially adding a way to exit the -// application properly after showing help message +// application properly after showing help message. func help(*cobra.Command, []string) { err := Root.Usage() if err != nil { diff --git a/cmd/root_test.go b/cmd/root_test.go index 3c0f0a1..63a59fb 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -25,7 +25,7 @@ func TestExecuteRootCmd(t *testing.T) { } } -// is this valid? dunno +// is this valid? dunno... func TestExecuteFunc(t *testing.T) { Execute() } diff --git a/cmd/version.go b/cmd/version.go index fb493b2..47e562e 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,10 +10,10 @@ import ( "github.com/spf13/cobra" ) -// version holds app version string +// version holds app version string. var version = "v0.0.13" -// used to determine whether to print short or long version string +// used to determine whether to print short or long version string. var shortVersion = false var cmdVersion = &cobra.Command{ @@ -30,7 +30,7 @@ var cmdVersion = &cobra.Command{ }, } -// get (short if -s/--short flag is supplied) version +// get (short if -s/--short flag is supplied) version. func getVersion() string { if !shortVersion { return appName + " - " + version @@ -38,12 +38,12 @@ func getVersion() string { return GetShortVersion() } -// GetShortVersion returns a bare version string +// GetShortVersion returns a bare version string. func GetShortVersion() string { return version } -// the init func registers the commands and flags with cobra +// the init func registers the commands and flags with cobra. func init() { cmdVersion.Flags().BoolVarP(&shortVersion, "short", "s", false, "print just the version string and nothing else") Root.AddCommand(cmdVersion) diff --git a/cmd/version_test.go b/cmd/version_test.go index ba7f5b9..2743080 100644 --- a/cmd/version_test.go +++ b/cmd/version_test.go @@ -46,7 +46,7 @@ func TestGetVersion(t *testing.T) { } } -// set shortVersion variable manually +// set shortVersion variable manually. func TestGetVersionWithShortVersionVar(t *testing.T) { shortVersion = true want := version @@ -58,7 +58,7 @@ func TestGetVersionWithShortVersionVar(t *testing.T) { } } -// explicitly get short version +// explicitly get short version. func TestGetShortVersion(t *testing.T) { want := version got := GetShortVersion() diff --git a/xkcdreader/about.go b/xkcdreader/about.go index 37de5f7..8aeee95 100644 --- a/xkcdreader/about.go +++ b/xkcdreader/about.go @@ -4,7 +4,7 @@ package xkcdreader import ( - // for embedding standard license header + // for embedding standard license header. _ "embed" "log" diff --git a/xkcdreader/app.go b/xkcdreader/app.go index c9c2e5b..d7319e6 100644 --- a/xkcdreader/app.go +++ b/xkcdreader/app.go @@ -23,7 +23,7 @@ const appGreeting = "welcome to go-xkcdreader" var a fyne.App -// RunApp performs sets up and runs the main application +// RunApp performs sets up and runs the main application. func RunApp() { // initialize the fyne application newApp() @@ -61,7 +61,7 @@ func getApp() fyne.App { return a } -// makeGreeting creates a greeting label +// makeGreeting creates a greeting label. func makeGreeting() *widget.Label { w := widget.NewLabel(appGreeting) w.TextStyle.Monospace = true @@ -134,7 +134,7 @@ func makeBrowseUI() *fyne.Container { return browseUI } -// get img from filesystem, resize it and return as *canvas.Image +// get img from filesystem, resize it and return as *canvas.Image. func getImg(imgPath string) *canvas.Image { _, err := os.Stat(imgPath)