2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

Merge pull request #3683 from MichaelEischer/fix-golangci-lint-warnings

Fix golangci lint warnings
This commit is contained in:
Alexander Neumann 2022-03-29 11:45:10 +02:00 committed by GitHub
commit db8a958991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 72 additions and 24 deletions

View File

@ -24,7 +24,7 @@ linters:
- govet
# make sure names and comments are used according to the conventions
- golint
- revive
# detect when assignments to existing variables are not used
- ineffassign
@ -51,7 +51,7 @@ issues:
# list of things to not warn about
exclude:
# golint: do not warn about missing comments for exported stuff
- exported (function|method|var|type|const) `.*` should have comment or be unexported
# golint: ignore constants in all caps
# revive: do not warn about missing comments for exported stuff
- exported (function|method|var|type|const) .* should have comment or be unexported
# revive: ignore constants in all caps
- don't use ALL_CAPS in Go names; use CamelCase

View File

@ -1,3 +1,4 @@
//go:build debug
// +build debug
package main

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package main

View File

@ -37,7 +37,7 @@ import (
"os/exec"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)
var version = "0.13.0-dev (compiled manually)"
@ -145,13 +145,13 @@ func checkErrno(err error) error {
}
func stdinIsTerminal() bool {
return terminal.IsTerminal(int(os.Stdin.Fd()))
return term.IsTerminal(int(os.Stdin.Fd()))
}
func stdoutIsTerminal() bool {
// mintty on windows can use pipes which behave like a posix terminal,
// but which are not a terminal handle
return terminal.IsTerminal(int(os.Stdout.Fd())) || stdoutCanUpdateStatus()
return term.IsTerminal(int(os.Stdout.Fd())) || stdoutCanUpdateStatus()
}
func stdoutCanUpdateStatus() bool {
@ -159,7 +159,7 @@ func stdoutCanUpdateStatus() bool {
}
func stdoutTerminalWidth() int {
w, _, err := terminal.GetSize(int(os.Stdout.Fd()))
w, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
return 0
}
@ -172,12 +172,12 @@ func stdoutTerminalWidth() int {
// program execution must revert changes to the terminal configuration itself.
// The terminal configuration is only restored while reading a password.
func restoreTerminal() {
if !terminal.IsTerminal(int(os.Stdout.Fd())) {
if !term.IsTerminal(int(os.Stdout.Fd())) {
return
}
fd := int(os.Stdout.Fd())
state, err := terminal.GetState(fd)
state, err := term.GetState(fd)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to get terminal state: %v\n", err)
return
@ -192,7 +192,7 @@ func restoreTerminal() {
if !isReadingPassword {
return nil
}
err := checkErrno(terminal.Restore(fd, state))
err := checkErrno(term.Restore(fd, state))
if err != nil {
fmt.Fprintf(os.Stderr, "unable to restore terminal state: %v\n", err)
}
@ -322,7 +322,7 @@ func readPassword(in io.Reader) (password string, err error) {
func readPasswordTerminal(in *os.File, out io.Writer, prompt string) (password string, err error) {
fmt.Fprint(out, prompt)
isReadingPassword = true
buf, err := terminal.ReadPassword(int(in.Fd()))
buf, err := term.ReadPassword(int(in.Fd()))
isReadingPassword = false
fmt.Fprintln(out)
if err != nil {

View File

@ -1,3 +1,4 @@
//go:build debug || profile
// +build debug profile
package main

View File

@ -1,3 +1,4 @@
//go:build !debug && !profile
// +build !debug,!profile
package main

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package main

View File

@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows
package main

View File

@ -1,4 +1,5 @@
//+build windows
//go:build windows
// +build windows
package main

1
go.mod
View File

@ -31,6 +31,7 @@ require (
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
golang.org/x/text v0.3.6
google.golang.org/api v0.50.0
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package archiver

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package archiver

View File

@ -1,3 +1,4 @@
//go:build aix || solaris
// +build aix solaris
package backend

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package backend_test

View File

@ -1,3 +1,4 @@
//go:build !aix && !solaris && !windows
// +build !aix,!solaris,!windows
package backend

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package local

View File

@ -22,7 +22,7 @@ type Cache struct {
free, size int // Current and max capacity, in bytes.
}
// Construct a blob cache that stores at most size bytes worth of blobs.
// New constructs a blob cache that stores at most size bytes worth of blobs.
func New(size int) *Cache {
c := &Cache{
free: size,

View File

@ -1,3 +1,4 @@
//go:build debug
// +build debug
package debug

View File

@ -1,3 +1,4 @@
//go:build !debug
// +build !debug
package debug

View File

@ -1,3 +1,4 @@
//go:build debug
// +build debug
package debug

View File

@ -1,3 +1,4 @@
//go:build !debug
// +build !debug
package debug

View File

@ -1,3 +1,4 @@
//go:build debug
// +build debug
package debug

View File

@ -1,3 +1,4 @@
//go:build !debug
// +build !debug
package debug

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package fs

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package fs

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package fs

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package fs

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package fs

View File

@ -117,7 +117,7 @@ func (fs *LocalVss) snapshotPath(path string) string {
fs.msgMessage("creating VSS snapshot for [%s]\n", vssVolume)
if snapshot, err := NewVssSnapshot(vssVolume, 120, fs.msgError); err != nil {
_ = fs.msgError(vssVolume, errors.Errorf("failed to create snapshot for [%s]: %s\n",
_ = fs.msgError(vssVolume, errors.Errorf("failed to create snapshot for [%s]: %s",
vssVolume, err))
fs.failedSnapshots[volumeNameLower] = struct{}{}
} else {

View File

@ -1,3 +1,4 @@
//go:build freebsd || darwin || netbsd
// +build freebsd darwin netbsd
package fs

View File

@ -1,3 +1,4 @@
//go:build !windows && !darwin && !freebsd && !netbsd
// +build !windows,!darwin,!freebsd,!netbsd
package fs

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package fs

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package fs

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package fs

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package fuse

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package fuse

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package fuse

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package fuse

View File

@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux
package fuse

View File

@ -56,7 +56,7 @@ func TestRoundTripperReader(t *testing.T) {
_, err := io.ReadFull(rand.Reader, data)
test.OK(t, err)
var send *tracedReadCloser = newTracedReadCloser(bytes.NewReader(data))
send := newTracedReadCloser(bytes.NewReader(data))
var recv *tracedReadCloser
rt := limiter.Transport(roundTripper(func(req *http.Request) (*http.Response, error) {

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package restic

View File

@ -1,3 +1,4 @@
//go:build !freebsd && !windows
// +build !freebsd,!windows
package restic

View File

@ -166,7 +166,7 @@ func (node *Node) CreateAt(ctx context.Context, path string, repo Repository) er
case "socket":
return nil
default:
return errors.Errorf("filetype %q not implemented!\n", node.Type)
return errors.Errorf("filetype %q not implemented", node.Type)
}
return nil

View File

@ -1,3 +1,4 @@
//go:build aix
// +build aix
package restic

View File

@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd
package restic

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package restic

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package restic

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin
// +build !linux,!darwin
package restorer

View File

@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows
package restorer

View File

@ -61,7 +61,7 @@ func TestCounter(t *testing.T) {
func TestCounterNil(t *testing.T) {
// Shouldn't panic.
var c *progress.Counter = nil
var c *progress.Counter
c.Add(1)
c.Done()
}

View File

@ -1,3 +1,4 @@
//go:build darwin || dragonfly || freebsd || netbsd || openbsd
// +build darwin dragonfly freebsd netbsd openbsd
package signals

View File

@ -1,3 +1,4 @@
//go:build aix || linux || solaris
// +build aix linux solaris
package signals

View File

@ -1,3 +1,4 @@
//go:build !linux
// +build !linux
package termstatus

View File

@ -10,7 +10,7 @@ import (
"strings"
"unicode"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
"golang.org/x/text/width"
)
@ -321,7 +321,7 @@ func (t *Terminal) SetStatus(lines []string) {
var width int
if t.canUpdateStatus {
var err error
width, _, err = terminal.GetSize(int(t.fd))
width, _, err = term.GetSize(int(t.fd))
if err != nil || width <= 0 {
// use 80 columns by default
width = 80

View File

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package termstatus
@ -6,7 +7,7 @@ import (
"io"
"os"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)
// clearCurrentLine removes all characters from the current line and resets the
@ -23,7 +24,7 @@ func moveCursorUp(wr io.Writer, fd uintptr) func(io.Writer, uintptr, int) {
// CanUpdateStatus returns true if status lines can be printed, the process
// output is not redirected to a file or pipe.
func CanUpdateStatus(fd uintptr) bool {
if !terminal.IsTerminal(int(fd)) {
if !term.IsTerminal(int(fd)) {
return false
}
term := os.Getenv("TERM")

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows
package termstatus