refactor: run go fmt ./... (#169)

This commit is contained in:
Simone Basso 2020-11-13 18:42:10 +01:00 committed by GitHub
parent c81393b31a
commit 163922e001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 197 additions and 205 deletions

View File

@ -6,9 +6,9 @@ import (
"github.com/alecthomas/kingpin" "github.com/alecthomas/kingpin"
"github.com/apex/log" "github.com/apex/log"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/cli/root" "github.com/ooni/probe-cli/internal/cli/root"
"github.com/ooni/probe-cli/internal/config" "github.com/ooni/probe-cli/internal/config"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/output" "github.com/ooni/probe-cli/internal/output"
"github.com/pkg/errors" "github.com/pkg/errors"
"gopkg.in/AlecAivazis/survey.v1" "gopkg.in/AlecAivazis/survey.v1"

View File

@ -3,9 +3,9 @@ package root
import ( import (
"github.com/alecthomas/kingpin" "github.com/alecthomas/kingpin"
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/log/handlers/batch" "github.com/ooni/probe-cli/internal/log/handlers/batch"
"github.com/ooni/probe-cli/internal/log/handlers/cli" "github.com/ooni/probe-cli/internal/log/handlers/cli"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/utils" "github.com/ooni/probe-cli/internal/utils"
"github.com/ooni/probe-cli/internal/version" "github.com/ooni/probe-cli/internal/version"
) )

View File

@ -6,11 +6,11 @@ import (
"github.com/alecthomas/kingpin" "github.com/alecthomas/kingpin"
"github.com/apex/log" "github.com/apex/log"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/cli/onboard" "github.com/ooni/probe-cli/internal/cli/onboard"
"github.com/ooni/probe-cli/internal/cli/root" "github.com/ooni/probe-cli/internal/cli/root"
"github.com/ooni/probe-cli/internal/database" "github.com/ooni/probe-cli/internal/database"
"github.com/ooni/probe-cli/internal/nettests" "github.com/ooni/probe-cli/internal/nettests"
"github.com/ooni/probe-cli/internal/ooni"
) )
func runNettestGroup(tg string, ctx *ooni.Context, network *database.Network) error { func runNettestGroup(tg string, ctx *ooni.Context, network *database.Network) error {

View File

@ -8,7 +8,6 @@ import (
"github.com/ooni/probe-cli/internal/version" "github.com/ooni/probe-cli/internal/version"
) )
func init() { func init() {
cmd := root.Command("version", "Show version.") cmd := root.Command("version", "Show version.")
cmd.Action(func(_ *kingpin.ParseContext) error { cmd.Action(func(_ *kingpin.ParseContext) error {

View File

@ -7,8 +7,8 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/database" "github.com/ooni/probe-cli/internal/database"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/output" "github.com/ooni/probe-cli/internal/output"
engine "github.com/ooni/probe-engine" engine "github.com/ooni/probe-engine"
"github.com/ooni/probe-engine/model" "github.com/ooni/probe-engine/model"

View File

@ -5,8 +5,8 @@ import (
"path" "path"
"testing" "testing"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/database" "github.com/ooni/probe-cli/internal/database"
"github.com/ooni/probe-cli/internal/ooni"
"github.com/ooni/probe-cli/internal/utils/shutil" "github.com/ooni/probe-cli/internal/utils/shutil"
) )

View File

@ -8,7 +8,6 @@ import (
"path/filepath" "path/filepath"
) )
type SameFileError struct { type SameFileError struct {
Src string Src string
Dst string Dst string
@ -35,7 +34,6 @@ func (e NotADirectoryError) Error() string {
return fmt.Sprintf("`%s` is not a directory", e.Src) return fmt.Sprintf("`%s` is not a directory", e.Src)
} }
type AlreadyExistsError struct { type AlreadyExistsError struct {
Dst string Dst string
} }
@ -44,7 +42,6 @@ func (e AlreadyExistsError) Error() string {
return fmt.Sprintf("`%s` already exists", e.Dst) return fmt.Sprintf("`%s` already exists", e.Dst)
} }
func samefile(src string, dst string) bool { func samefile(src string, dst string) bool {
srcInfo, _ := os.Stat(src) srcInfo, _ := os.Stat(src)
dstInfo, _ := os.Stat(dst) dstInfo, _ := os.Stat(dst)
@ -68,13 +65,12 @@ func IsSymlink(fi os.FileInfo) bool {
return (fi.Mode() & os.ModeSymlink) == os.ModeSymlink return (fi.Mode() & os.ModeSymlink) == os.ModeSymlink
} }
// Copy data from src to dst // Copy data from src to dst
// //
// If followSymlinks is not set and src is a symbolic link, a // If followSymlinks is not set and src is a symbolic link, a
// new symlink will be created instead of copying the file it points // new symlink will be created instead of copying the file it points
// to. // to.
func CopyFile(src, dst string, followSymlinks bool) (error) { func CopyFile(src, dst string, followSymlinks bool) error {
if samefile(src, dst) { if samefile(src, dst) {
return &SameFileError{src, dst} return &SameFileError{src, dst}
} }
@ -139,7 +135,6 @@ func CopyFile(src, dst string, followSymlinks bool) (error) {
return nil return nil
} }
// Copy mode bits from src to dst. // Copy mode bits from src to dst.
// //
// If followSymlinks is false, symlinks aren't followed if and only // If followSymlinks is false, symlinks aren't followed if and only
@ -168,7 +163,6 @@ func CopyMode(src, dst string, followSymlinks bool) error {
return err return err
} }
// Copy data and mode bits ("cp src dst"). Return the file's destination. // Copy data and mode bits ("cp src dst"). Return the file's destination.
// //
// The destination may be a directory. // The destination may be a directory.
@ -178,7 +172,7 @@ func CopyMode(src, dst string, followSymlinks bool) error {
// //
// If source and destination are the same file, a SameFileError will be // If source and destination are the same file, a SameFileError will be
// rased. // rased.
func Copy(src, dst string, followSymlinks bool) (string, error){ func Copy(src, dst string, followSymlinks bool) (string, error) {
dstInfo, err := os.Stat(dst) dstInfo, err := os.Stat(dst)
if err == nil && dstInfo.Mode().IsDir() { if err == nil && dstInfo.Mode().IsDir() {
@ -205,8 +199,8 @@ func Copy(src, dst string, followSymlinks bool) (string, error){
type CopyTreeOptions struct { type CopyTreeOptions struct {
Symlinks bool Symlinks bool
IgnoreDanglingSymlinks bool IgnoreDanglingSymlinks bool
CopyFunction func (string, string, bool) (string, error) CopyFunction func(string, string, bool) (string, error)
Ignore func (string, []os.FileInfo) []string Ignore func(string, []os.FileInfo) []string
} }
// Recursively copy a directory tree. // Recursively copy a directory tree.
@ -242,13 +236,12 @@ type CopyTreeOptions struct {
// exists) can be used. // exists) can be used.
func CopyTree(src, dst string, options *CopyTreeOptions) error { func CopyTree(src, dst string, options *CopyTreeOptions) error {
if options == nil { if options == nil {
options = &CopyTreeOptions{Symlinks:false, options = &CopyTreeOptions{Symlinks: false,
Ignore:nil, Ignore: nil,
CopyFunction:Copy, CopyFunction: Copy,
IgnoreDanglingSymlinks:false} IgnoreDanglingSymlinks: false}
} }
srcFileInfo, err := os.Stat(src) srcFileInfo, err := os.Stat(src)
if err != nil { if err != nil {
return err return err