mirror of
https://codeberg.org/scip/anydb.git
synced 2026-10-08 03:04:20 +02:00
update linter config, satisfy linter (#28)
This commit is contained in:
@@ -24,11 +24,11 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"codeberg.org/scip/anydb/app"
|
||||
"codeberg.org/scip/anydb/cfg"
|
||||
"github.com/dustin/go-humanize"
|
||||
"golang.org/x/term"
|
||||
//"github.com/alecthomas/repr"
|
||||
// "github.com/alecthomas/repr"
|
||||
)
|
||||
|
||||
func Print(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEntry) error {
|
||||
@@ -40,17 +40,18 @@ func Print(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEn
|
||||
|
||||
switch conf.Mode {
|
||||
case "simple", "":
|
||||
if entry.Binary {
|
||||
if entry.GetBinary() {
|
||||
if isatty {
|
||||
fmt.Println("binary data omitted")
|
||||
} else {
|
||||
if _, err := os.Stdout.WriteString(entry.Value); err != nil {
|
||||
if _, err := os.Stdout.WriteString(entry.GetValue()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Print(string(entry.Value))
|
||||
if entry.Value[entry.Size-1] != '\n' {
|
||||
fmt.Print(entry.GetValue())
|
||||
|
||||
if entry.GetValue()[entry.GetSize()-1] != '\n' {
|
||||
// always add a terminal newline
|
||||
fmt.Println()
|
||||
}
|
||||
@@ -72,8 +73,10 @@ func Print(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEn
|
||||
}
|
||||
|
||||
func WriteFile(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEntry) error {
|
||||
var fileHandle *os.File
|
||||
var err error
|
||||
var (
|
||||
fileHandle *os.File
|
||||
err error
|
||||
)
|
||||
|
||||
if attr.File == "-" {
|
||||
fileHandle = os.Stdout
|
||||
@@ -92,10 +95,10 @@ func WriteFile(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.
|
||||
}
|
||||
|
||||
// actually write file content
|
||||
_, err = fileHandle.WriteString(entry.Value)
|
||||
_, err = fileHandle.WriteString(entry.GetValue())
|
||||
|
||||
if !entry.Binary {
|
||||
if entry.Value[entry.Size-1] != '\n' {
|
||||
if !entry.GetBinary() {
|
||||
if entry.GetValue()[entry.GetSize()-1] != '\n' {
|
||||
// always add a terminal newline
|
||||
_, err = fileHandle.Write([]byte{'\n'})
|
||||
}
|
||||
@@ -137,7 +140,7 @@ func Info(writer io.Writer, conf *cfg.Config, info *app.DbInfo) error {
|
||||
|
||||
if conf.Debug {
|
||||
val := reflect.ValueOf(&bucket.Stats).Elem()
|
||||
for i := 0; i < val.NumField(); i++ {
|
||||
for i := range val.NumField() {
|
||||
if _, err := fmt.Fprintf(writer, "%19s: %v\n", val.Type().Field(i).Name, val.Field(i)); err != nil {
|
||||
return fmt.Errorf("failed to write output: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user