From 483ed58b8df9e7ce3d195e02a27481d43d9b175b Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Sun, 7 Apr 2019 18:15:38 +0200 Subject: [PATCH] * Removed unnecessary string concatenations in Print statements. * Fixed .footer.goph layout. --- config.go | 8 ++++---- gogopherd.go | 9 ++++----- samplehole/.footer.goph | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/config.go b/config.go index 83c1cc5..5e85983 100644 --- a/config.go +++ b/config.go @@ -44,7 +44,7 @@ var cfg = struct { } func parseConfigFile(filename string) error { - tracer.Print("reading config from " + filename) + tracer.Print("reading config from ", filename) file, err := ioutil.ReadFile(filename) if err != nil { logger.Print("ReadFile: ", err.Error()) @@ -59,7 +59,7 @@ func parseConfigFile(filename string) error { assign := strings.Split(line, "=") name := strings.ToLower(strings.TrimSpace(assign[0])) val := strings.Trim(strings.TrimSpace(assign[1]), "\"") - tracer.Print(name + "=" + val) + tracer.Print(name, "=", val) switch name { case "iface": cfg.iface = val @@ -82,7 +82,7 @@ func parseConfigFile(filename string) error { case "indexes": cfg.indexes = strToBool(val) default: - logger.Print("ignoring unknown config item: " + name) + logger.Print("ignoring unknown config item: ", name) } } return nil @@ -136,7 +136,7 @@ func initialize() { cfg.idxpage = "" } - tracer.Print("Version ", version) + tracer.Print("Version: ", version) tracer.Print("fqdn: ", cfg.fqdn) tracer.Print("iface: ", cfg.iface) tracer.Print("port: ", cfg.port) diff --git a/gogopherd.go b/gogopherd.go index 2e63a0d..af26bcb 100644 --- a/gogopherd.go +++ b/gogopherd.go @@ -20,7 +20,6 @@ import ( "net" "os" "path/filepath" - "strconv" "strings" ) @@ -77,7 +76,7 @@ func createIndex(dirname string, selector string) (string, error) { } } } else { - logger.Print("unhandled file mode: " + fi.Name() + " (" + fmode.String() + ")") + logger.Print("unhandled file mode: ", fi.Name(), " (", fmode.String(), ")") } } return list, error(nil) @@ -149,7 +148,7 @@ func sendError(conn net.Conn, msg string) { nbytes += int64(nb1) nb2, _ := sendFooter(conn) nbytes += nb2 - tracer.Printf("%d bytes sent.", nbytes) + tracer.Print(nbytes, " bytes sent.") return } @@ -204,7 +203,7 @@ func handleRequest(conn net.Conn) { idxpath := path + pathSep + cfg.idxpage nbytes, err = sendFile(conn, idxpath) if err != nil { - tracer.Print("no index file in " + path) + tracer.Print("no index file in ", path) } } if err != nil { @@ -230,7 +229,7 @@ func handleRequest(conn net.Conn) { sendError(conn, "404") return } - tracer.Print(strconv.FormatInt(nbytes, 10) + " bytes sent.") + tracer.Print(nbytes, " bytes sent.") return } diff --git a/samplehole/.footer.goph b/samplehole/.footer.goph index f03528f..a04c2fc 100644 --- a/samplehole/.footer.goph +++ b/samplehole/.footer.goph @@ -1,3 +1,3 @@ i Err localhost 7070 -i__________________________________________ Err localhost 7070 +i------------------------------------------ Err localhost 7070 iThis page was brought to you by gogopherd. Err localhost 7070 -- 2.30.2