From 69b19e2fa3d33c580f2252b2f853661d38a8a600 Mon Sep 17 00:00:00 2001 From: emp-temp Date: Sun, 17 Sep 2023 02:36:10 +0900 Subject: [PATCH 1/3] refactor: transition from ioutil.ReadFile to os.ReadFile --- go.mod | 2 +- go.sum | 1 - main.go | 7 +++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6686e60..34d6748 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mattn/memo -go 1.13 +go 1.16 require ( github.com/BurntSushi/toml v0.3.1 diff --git a/go.sum b/go.sum index 5973e3e..d13fef3 100644 --- a/go.sum +++ b/go.sum @@ -88,7 +88,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go index e80855f..ed26724 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "fmt" "html/template" "io" - "io/ioutil" "log" "net/http" "os" @@ -306,7 +305,7 @@ func run() int { } func firstline(name string) string { - b, err := ioutil.ReadFile(name) + b, err := os.ReadFile(name) if err != nil { return "" } @@ -508,7 +507,7 @@ func cmdNew(c *cli.Context) error { tmplString := templateMemoContent if fileExists(cfg.MemoTemplate) { - b, err := ioutil.ReadFile(cfg.MemoTemplate) + b, err := os.ReadFile(cfg.MemoTemplate) if err != nil { return err } @@ -817,7 +816,7 @@ func cmdServe(c *cli.Context) error { } } else { p := filepath.Join(cfg.MemoDir, escape(req.URL.Path)) - b, err := ioutil.ReadFile(p) + b, err := os.ReadFile(p) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return From 76acee499a09ae274852b04c4c4955d63eb2a42e Mon Sep 17 00:00:00 2001 From: emp-temp Date: Sun, 17 Sep 2023 03:05:31 +0900 Subject: [PATCH 2/3] chore: Update Go version from 1.16 to 1.21 --- go.mod | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 34d6748..0f5f5dc 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,36 @@ module github.com/mattn/memo -go 1.16 +go 1.21 require ( github.com/BurntSushi/toml v0.3.1 - github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect github.com/fatih/color v1.12.0 github.com/mattn/go-colorable v0.1.8 github.com/mattn/go-isatty v0.0.13 github.com/mattn/go-runewidth v0.0.13 github.com/mattn/go-tty v0.0.3 - github.com/microcosm-cc/bluemonday v1.0.15 // indirect github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 + github.com/shurcooL/github_flavored_markdown v0.0.0-20210228213109-c3a9aa474629 + github.com/urfave/cli/v2 v2.3.0 +) + +require ( + github.com/aymerick/douceur v0.2.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect + github.com/gorilla/css v1.0.0 // indirect + github.com/microcosm-cc/bluemonday v1.0.15 // indirect + github.com/rivo/uniseg v0.2.0 // indirect github.com/russross/blackfriday v1.6.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect - github.com/shurcooL/github_flavored_markdown v0.0.0-20210228213109-c3a9aa474629 github.com/shurcooL/go v0.0.0-20180410215514-47fa5b7ceee6 // indirect github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 // indirect github.com/shurcooL/highlight_diff v0.0.0-20181222201841-111da2e7d480 // indirect github.com/shurcooL/highlight_go v0.0.0-20191220051317-782971ddf21b // indirect github.com/shurcooL/octicon v0.0.0-20191102190552-cbb32d6a785c // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect - github.com/urfave/cli/v2 v2.3.0 golang.org/x/net v0.0.0-20210716203947-853a461950ff // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect ) From eb2afb908fc59739d01b4ccea797dc5931207d27 Mon Sep 17 00:00:00 2001 From: emp-temp Date: Mon, 18 Sep 2023 21:41:07 +0900 Subject: [PATCH 3/3] refactor: change build tag --- util_posix.go | 2 +- util_windows.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util_posix.go b/util_posix.go index 3d4dd9b..c858878 100644 --- a/util_posix.go +++ b/util_posix.go @@ -1,4 +1,4 @@ -// +build !windows +//go:build !windows package main diff --git a/util_windows.go b/util_windows.go index dba2e1e..958612b 100644 --- a/util_windows.go +++ b/util_windows.go @@ -1,4 +1,4 @@ -// +build windows +//go:build !windows package main