From 6ace647b01b923f158a5bb1b8af0e8573eb347d9 Mon Sep 17 00:00:00 2001 From: Inhere Date: Fri, 9 Dec 2022 21:50:10 +0800 Subject: [PATCH] :bulb: chore: add package comment or exported var comment --- cliutil/termctrl/keyboard.go | 7 +++++-- cliutil/termctrl/termctrl.go | 2 ++ envutil/envutil.go | 1 + errorx/errors.go | 2 ++ fsutil/check.go | 4 +++- mathutil/mathutil.go | 1 + netutil/httpctype/content_type.go | 2 +- netutil/httpctype/mime_type.go | 2 +- netutil/httpreq/response.go | 8 ++++---- sysutil/cmdr/runner.go | 1 + 10 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 cliutil/termctrl/termctrl.go diff --git a/cliutil/termctrl/keyboard.go b/cliutil/termctrl/keyboard.go index 2ecb0ed47..7910328bb 100644 --- a/cliutil/termctrl/keyboard.go +++ b/cliutil/termctrl/keyboard.go @@ -74,5 +74,8 @@ const ( KeyAlt = ' ' ) -var PasteStart = []byte{KeyEscape, '[', '2', '0', '0', '~'} -var PasteEnd = []byte{KeyEscape, '[', '2', '0', '1', '~'} +// special chars on paste start or end +var ( + PasteStart = []byte{KeyEscape, '[', '2', '0', '0', '~'} + PasteEnd = []byte{KeyEscape, '[', '2', '0', '1', '~'} +) diff --git a/cliutil/termctrl/termctrl.go b/cliutil/termctrl/termctrl.go new file mode 100644 index 000000000..9782c8610 --- /dev/null +++ b/cliutil/termctrl/termctrl.go @@ -0,0 +1,2 @@ +// Package termctrl provide some simple term control utils +package termctrl diff --git a/envutil/envutil.go b/envutil/envutil.go index 9680cefdd..fc1d07592 100644 --- a/envutil/envutil.go +++ b/envutil/envutil.go @@ -1,3 +1,4 @@ +// Package envutil provide some commonly ENV util functions. package envutil import ( diff --git a/errorx/errors.go b/errorx/errors.go index a87c2b3c7..6a16e896f 100644 --- a/errorx/errors.go +++ b/errorx/errors.go @@ -110,6 +110,8 @@ func (e ErrMap) One() error { // Errors multi error list type Errors []error + +// ErrList alias for Errors type ErrList = Errors // Error string diff --git a/fsutil/check.go b/fsutil/check.go index 4411b3988..67ca4f9e5 100644 --- a/fsutil/check.go +++ b/fsutil/check.go @@ -6,12 +6,14 @@ import ( "path" ) +// perm for create dir or file var ( - // DefaultDirPerm perm and flags for create log file DefaultDirPerm os.FileMode = 0775 DefaultFilePerm os.FileMode = 0665 OnlyReadFilePerm os.FileMode = 0444 +) +var ( // DefaultFileFlags for create and write DefaultFileFlags = os.O_CREATE | os.O_WRONLY | os.O_APPEND // OnlyReadFileFlags open file for read diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go index c379efc5b..e27c6708a 100644 --- a/mathutil/mathutil.go +++ b/mathutil/mathutil.go @@ -1,3 +1,4 @@ +// Package mathutil provide math(int, number) util functions. eg: convert, math calc, random package mathutil import "math" diff --git a/netutil/httpctype/content_type.go b/netutil/httpctype/content_type.go index 98cf9f423..517c14caf 100644 --- a/netutil/httpctype/content_type.go +++ b/netutil/httpctype/content_type.go @@ -3,7 +3,7 @@ package httpctype const Key = "Content-Type" -// HTTP Content-Type with charset of the most common data formats. +// there are some HTTP Content-Type with charset of the most common data formats. const ( CSS = "text/css; charset=utf-8" HTML = "text/html; charset=utf-8" diff --git a/netutil/httpctype/mime_type.go b/netutil/httpctype/mime_type.go index 7a4492882..96121dad9 100644 --- a/netutil/httpctype/mime_type.go +++ b/netutil/httpctype/mime_type.go @@ -1,6 +1,6 @@ package httpctype -// Content-Type MIME of the most common data formats. +// there are some Content-Type MIME of the most common data formats. const ( MIMEHTML = "text/html" MIMEText = "text/plain" // equals MIMEPlain diff --git a/netutil/httpreq/response.go b/netutil/httpreq/response.go index 77dae95c0..e66e5059d 100644 --- a/netutil/httpreq/response.go +++ b/netutil/httpreq/response.go @@ -77,10 +77,10 @@ func (r *Resp) BodyBuffer() *bytes.Buffer { return buf } -// BindJsonOnOk body data on status is 200 +// BindJSONOnOk body data on status is 200 // // NOTICE: must close resp body. -func (r *Resp) BindJsonOnOk(ptr any) error { +func (r *Resp) BindJSONOnOk(ptr any) error { // NOTICE: must close resp body. defer r.QuiteCloseBody() @@ -96,10 +96,10 @@ func (r *Resp) BindJsonOnOk(ptr any) error { return json.NewDecoder(r.Body).Decode(ptr) } -// BindJson body data to a ptr +// BindJSON body data to a ptr // // NOTICE: must close resp body. -func (r *Resp) BindJson(ptr any) error { +func (r *Resp) BindJSON(ptr any) error { // NOTICE: must close resp body. defer r.QuiteCloseBody() diff --git a/sysutil/cmdr/runner.go b/sysutil/cmdr/runner.go index c01ffd977..dacc1301f 100644 --- a/sysutil/cmdr/runner.go +++ b/sysutil/cmdr/runner.go @@ -24,6 +24,7 @@ type Task struct { PrevCond func(prev *Task) bool } +// NewTask instance func NewTask(cmd *Cmd) *Task { return &Task{ Cmd: cmd,