diff --git a/pkg/dflog/log.go b/pkg/dflog/log.go index c1055411b..28bddbaac 100644 --- a/pkg/dflog/log.go +++ b/pkg/dflog/log.go @@ -84,7 +84,7 @@ func WithMaxSizeMB(max uint) Option { } } -// WithConsole add a hook to output logs to stdout +// WithConsole adds a hook to output logs to stdout func WithConsole() Option { return func(l *logrus.Logger) error { consoleLog := &logrus.Logger{ diff --git a/pkg/limitreader/limit_reader.go b/pkg/limitreader/limit_reader.go index 5d4b7d602..9ead0bdf1 100644 --- a/pkg/limitreader/limit_reader.go +++ b/pkg/limitreader/limit_reader.go @@ -25,14 +25,14 @@ import ( "github.com/dragonflyoss/Dragonfly/pkg/ratelimiter" ) -// NewLimitReader create LimitReader +// NewLimitReader creates LimitReader // src: reader // rate: bytes/second func NewLimitReader(src io.Reader, rate int, calculateMd5 bool) *LimitReader { return NewLimitReaderWithLimiter(newRateLimiterWithDefaultWindow(rate), src, calculateMd5) } -// NewLimitReaderWithLimiter create LimitReader with a rateLimiter. +// NewLimitReaderWithLimiter creates LimitReader with a rateLimiter. // src: reader // rate: bytes/second func NewLimitReaderWithLimiter(rl *ratelimiter.RateLimiter, src io.Reader, calculateMd5 bool) *LimitReader { @@ -47,14 +47,14 @@ func NewLimitReaderWithLimiter(rl *ratelimiter.RateLimiter, src io.Reader, calcu } } -// NewLimitReaderWithMD5Sum create LimitReader with a md5 sum. +// NewLimitReaderWithMD5Sum creates LimitReader with a md5 sum. // src: reader // rate: bytes/second func NewLimitReaderWithMD5Sum(src io.Reader, rate int, md5sum hash.Hash) *LimitReader { return NewLimitReaderWithLimiterAndMD5Sum(src, newRateLimiterWithDefaultWindow(rate), md5sum) } -// NewLimitReaderWithLimiterAndMD5Sum create LimitReader with rateLimiter and md5 sum. +// NewLimitReaderWithLimiterAndMD5Sum creates LimitReader with rateLimiter and md5 sum. // src: reader // rate: bytes/second func NewLimitReaderWithLimiterAndMD5Sum(src io.Reader, rl *ratelimiter.RateLimiter, md5sum hash.Hash) *LimitReader { @@ -90,7 +90,7 @@ func (lr *LimitReader) Read(p []byte) (n int, err error) { return n, e } -// Md5 calculate the md5 of all contents read +// Md5 calculates the md5 of all contents read func (lr *LimitReader) Md5() string { if lr.md5sum != nil { return fmt.Sprintf("%x", lr.md5sum.Sum(nil)) diff --git a/pkg/netutils/netutils.go b/pkg/netutils/netutils.go index 2e740599a..ecc571455 100644 --- a/pkg/netutils/netutils.go +++ b/pkg/netutils/netutils.go @@ -119,7 +119,7 @@ func ExtractHost(hostAndPort string) string { return fields[0] } -// GetIPAndPortFromNode return ip and port by parsing the node value. +// GetIPAndPortFromNode returns ip and port by parsing the node value. // It will return defaultPort as the value of port // when the node is a string without port or with an illegal port. func GetIPAndPortFromNode(node string, defaultPort int) (string, int) { @@ -260,7 +260,7 @@ func ConvertTimeIntToString(timestamp int64) (string, error) { return fmt.Sprintf("%s%s", timeString[:len(timeString)-3], layoutGMT), nil } -// slice2Map translate a slice to a map with +// slice2Map translates a slice to a map with // the value in slice as the key and true as the value. func slice2Map(value []string) map[string]bool { mmap := make(map[string]bool) @@ -278,7 +278,7 @@ func isExist(mmap map[string]bool, key string) bool { return false } -// CalculateTimeout calculate the timeout(in seconds) according to the fileLength and the min rate of network. +// CalculateTimeout calculates the timeout(in seconds) according to the fileLength and the min rate of network. // // The 0 will be returned when both minRate and defaultMinRate both are <=0. func CalculateTimeout(fileLength int64, minRate int, defaultMinRate int, reservedTime time.Duration) time.Duration { diff --git a/test/command/cmd.go b/test/command/cmd.go index 30a6179d2..a7d31acc4 100644 --- a/test/command/cmd.go +++ b/test/command/cmd.go @@ -235,7 +235,7 @@ func (s *Starter) kill(cmd *exec.Cmd) { } } -// execCmd execute a command. +// execCmd executes a command. // param running indicates that how much time the process can run at most, // after the running duration, the process will be killed automatically. // When the value of running is less than 0, it will not be killed automatically, diff --git a/test/util_api.go b/test/util_api.go index a4d4d1e72..4c830db87 100644 --- a/test/util_api.go +++ b/test/util_api.go @@ -36,7 +36,7 @@ func CheckRespStatus(c *check.C, resp *http.Response, status int) { } } -// CheckMetric find the specific metric from /metrics endpoint and it will compare the metric +// CheckMetric finds the specific metric from /metrics endpoint and it will compare the metric // value with expected value. func CheckMetric(c *check.C, metric string, value float64) { var val float64 diff --git a/version/version.go b/version/version.go index 7d9a91c91..e596efdeb 100644 --- a/version/version.go +++ b/version/version.go @@ -107,7 +107,7 @@ func Print(program string) string { return strings.TrimSpace(buf.String()) } -// NewBuildInfo register a collector which exports metrics about version and build information. +// NewBuildInfo registers a collector which exports metrics about version and build information. func NewBuildInfo(program string, registerer prometheus.Registerer) { buildInfo := metricsutils.NewGauge(program, "build_info", fmt.Sprintf("A metric with a constant '1' value labeled by version, revision, os, "+