Skip to content

Commit

Permalink
bulk gofmt -s update
Browse files Browse the repository at this point in the history
This change is 100% gofmt generated.  The gometalinter and goreportcard
highlighted this set of files as "not gofmted with -s (gofmt)", so they're
run through gofmt to correct the noted issues.

Most changes are minimal stylistic changes, and gofmt is _the_ style
authority.

The changes in cmds/stty/termios_linux.go and pkg/gpt/data.go are
perhaps less obvious.  In both cases the map definition has a
detailed explicit type, which makes the stating the type in the
instantiations redudant and thus gofmt removes that leading text.

Signed-off-by: Tim Pepper <tpepper@vmware.com>
  • Loading branch information
Tim Pepper committed Oct 10, 2017
1 parent e6277a5 commit 2b17a7b
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 307 deletions.
2 changes: 1 addition & 1 deletion cmds/cat/cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
"path/filepath"
)

// setup writes a set of files, putting 1 byte in each file.
Expand Down
2 changes: 1 addition & 1 deletion cmds/ed/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Command(f Editor, c string, startLine, endLine int) error {
a := c[1:]
debug("Process %c, args %v", c[0], a)
switch c[0] {
case 'q', 'e':
case 'q', 'e':
if f.IsDirty() {
f.Dirty(false)
return fmt.Errorf("f was dirty, no longer is, try again")
Expand Down
2 changes: 1 addition & 1 deletion cmds/ed/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (f *file) Read(r io.Reader, startLine, endLine int) (int, error) {
// Write writes the lines out from start to end, inclusive.
// dot is unchanged.
func (f *file) Write(w io.Writer, startLine, endLine int) (int, error) {
if endLine < startLine || startLine < 1 || endLine > len(f.lines) + 1 {
if endLine < startLine || startLine < 1 || endLine > len(f.lines)+1 {
return -1, fmt.Errorf("file is %d lines and [start, end] is [%d, %d]", len(f.lines), startLine, endLine)
}

Expand Down
25 changes: 12 additions & 13 deletions cmds/ip/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ func one(cmd string, cmds []string) string {
return ""
}


// in the ip command, turns out 'dev' is a noise word.
// The BNF is not right there either.
// Always make it optional.
func dev() netlink.Link {
cursor++
whatIWant = []string{"dev", "device name",}
whatIWant = []string{"dev", "device name"}
if arg[cursor] == "dev" {
cursor++
}
whatIWant = []string{"device name",}
whatIWant = []string{"device name"}
iface, err := netlink.LinkByName(arg[cursor])
if err != nil {
usage()
Expand Down Expand Up @@ -103,13 +102,13 @@ func addrip() {
return
}
cursor++
whatIWant = []string{"add", "del",}
whatIWant = []string{"add", "del"}
cmd := arg[cursor]

switch one(cmd, whatIWant) {
case "add", "del":
cursor++
whatIWant = []string{"CIDR format address",}
whatIWant = []string{"CIDR format address"}
addr, err = netlink.ParseAddr(arg[cursor])
if err != nil {
usage()
Expand All @@ -136,7 +135,7 @@ func addrip() {

func linkshow() {
cursor++
whatIWant = []string{"<nothing>", "<device name>",}
whatIWant = []string{"<nothing>", "<device name>"}
if len(arg[cursor:]) == 0 {
showips()
}
Expand All @@ -145,7 +144,7 @@ func linkshow() {
func linkset() {
iface := dev()
cursor++
whatIWant = []string{"up", "down",}
whatIWant = []string{"up", "down"}
switch one(arg[cursor], whatIWant) {
case "up":
if err := netlink.LinkSetUp(iface); err != nil {
Expand All @@ -162,7 +161,7 @@ func linkset() {

func link() {
cursor++
whatIWant = []string{"show", "set",}
whatIWant = []string{"show", "set"}
cmd := arg[cursor]

switch one(cmd, whatIWant) {
Expand All @@ -185,19 +184,19 @@ func routeshow() {
}
func nodespec() string {
cursor++
whatIWant = []string{"default", "CIDR",}
whatIWant = []string{"default", "CIDR"}
return arg[cursor]
}

func nexthop() (string, *netlink.Addr) {
cursor++
whatIWant = []string{"via",}
whatIWant = []string{"via"}
if arg[cursor] != "via" {
usage()
}
nh := arg[cursor]
cursor++
whatIWant = []string{"Gateway CIDR",}
whatIWant = []string{"Gateway CIDR"}
addr, err := netlink.ParseAddr(arg[cursor])
if err != nil {
log.Fatalf("Gateway CIDR: %v", err)
Expand Down Expand Up @@ -239,7 +238,7 @@ func route() {
return
}

whatIWant = []string{"show", "add",}
whatIWant = []string{"show", "add"}
switch one(arg[cursor], whatIWant) {
case "show":
routeshow()
Expand All @@ -252,7 +251,7 @@ func route() {
}
func main() {
// When this is embedded in busybox we need to reinit some things.
whatIWant = []string{"addr", "route", "link",}
whatIWant = []string{"addr", "route", "link"}
cursor = 0
flag.Parse()
arg = flag.Args()
Expand Down
4 changes: 2 additions & 2 deletions cmds/mm/mm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var (
dest = flag.String("d", "/u", "destination directory")
dest = flag.String("d", "/u", "destination directory")
namespace = []uroot.Creator{
uroot.Dir{Name: "proc", Mode: os.FileMode(0555)},
uroot.Dir{Name: "sys", Mode: os.FileMode(0555)},
Expand All @@ -42,7 +42,7 @@ var (
uroot.Mount{Source: "none", Target: "dev/pts", FSType: "devpts", Flags: syscall.MS_MGC_VAL, Opts: "newinstance,ptmxmode=666,gid=5,mode=620"},
uroot.Symlink{Linkpath: "/dev/pts/ptmx", Target: "dev/ptmx"},
}
commands = []*exec.Cmd {
commands = []*exec.Cmd{
exec.Command("minimega", "-e", "vm", "config", "filesystem"),
exec.Command("minimega", "-e", "vm", "config", "snapshot", "false"),
exec.Command("minimega", "-e", "vm", "launch", "container", "uroot"),
Expand Down
2 changes: 1 addition & 1 deletion cmds/mv/mv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"io/ioutil"
"os"
"testing"
"path/filepath"
"testing"
)

type makeit struct {
Expand Down
2 changes: 1 addition & 1 deletion cmds/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func isPermutation(check string, ref string) bool {
sort.Strings(checkArray)
sort.Strings(refArray)

for i, _ := range check {
for i := range check {
if checkArray[i] != refArray[i] {
return false
}
Expand Down
88 changes: 44 additions & 44 deletions cmds/stty/termios_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,57 @@ type bit struct {
var (
boolFields = map[string]*bit{
// Input processing
"ignbrk": &bit{word: I, mask: syscall.IGNBRK},
"brkint": &bit{word: I, mask: syscall.BRKINT},
"ignpar": &bit{word: I, mask: syscall.IGNPAR},
"parmrk": &bit{word: I, mask: syscall.PARMRK},
"inpck": &bit{word: I, mask: syscall.INPCK},
"istrip": &bit{word: I, mask: syscall.ISTRIP},
"inlcr": &bit{word: I, mask: syscall.INLCR},
"igncr": &bit{word: I, mask: syscall.IGNCR},
"icrnl": &bit{word: I, mask: syscall.ICRNL},
"iuclc": &bit{word: I, mask: syscall.IUCLC},
"ixon": &bit{word: I, mask: syscall.IXON},
"ixany": &bit{word: I, mask: syscall.IXANY},
"ixoff": &bit{word: I, mask: syscall.IXOFF},
"imaxbel": &bit{word: I, mask: syscall.IMAXBEL},
"iutf8": &bit{word: I, mask: syscall.IUTF8},
"ignbrk": {word: I, mask: syscall.IGNBRK},
"brkint": {word: I, mask: syscall.BRKINT},
"ignpar": {word: I, mask: syscall.IGNPAR},
"parmrk": {word: I, mask: syscall.PARMRK},
"inpck": {word: I, mask: syscall.INPCK},
"istrip": {word: I, mask: syscall.ISTRIP},
"inlcr": {word: I, mask: syscall.INLCR},
"igncr": {word: I, mask: syscall.IGNCR},
"icrnl": {word: I, mask: syscall.ICRNL},
"iuclc": {word: I, mask: syscall.IUCLC},
"ixon": {word: I, mask: syscall.IXON},
"ixany": {word: I, mask: syscall.IXANY},
"ixoff": {word: I, mask: syscall.IXOFF},
"imaxbel": {word: I, mask: syscall.IMAXBEL},
"iutf8": {word: I, mask: syscall.IUTF8},

//Outputprocessing
"opost": &bit{word: O, mask: syscall.OPOST},
"olcuc": &bit{word: O, mask: syscall.OLCUC},
"onlcr": &bit{word: O, mask: syscall.ONLCR},
"ocrnl": &bit{word: O, mask: syscall.OCRNL},
"onocr": &bit{word: O, mask: syscall.ONOCR},
"onlret": &bit{word: O, mask: syscall.ONLRET},
"ofill": &bit{word: O, mask: syscall.OFILL},
"ofdel": &bit{word: O, mask: syscall.OFDEL},
"opost": {word: O, mask: syscall.OPOST},
"olcuc": {word: O, mask: syscall.OLCUC},
"onlcr": {word: O, mask: syscall.ONLCR},
"ocrnl": {word: O, mask: syscall.OCRNL},
"onocr": {word: O, mask: syscall.ONOCR},
"onlret": {word: O, mask: syscall.ONLRET},
"ofill": {word: O, mask: syscall.OFILL},
"ofdel": {word: O, mask: syscall.OFDEL},

//Localprocessing
"isig": &bit{word: L, mask: syscall.ISIG},
"icanon": &bit{word: L, mask: syscall.ICANON},
"xcase": &bit{word: L, mask: syscall.XCASE},
"echo": &bit{word: L, mask: syscall.ECHO},
"echoe": &bit{word: L, mask: syscall.ECHOE},
"echok": &bit{word: L, mask: syscall.ECHOK},
"echonl": &bit{word: L, mask: syscall.ECHONL},
"noflsh": &bit{word: L, mask: syscall.NOFLSH},
"tostop": &bit{word: L, mask: syscall.TOSTOP},
"echoctl": &bit{word: L, mask: syscall.ECHOCTL},
"echoprt": &bit{word: L, mask: syscall.ECHOPRT},
"echoke": &bit{word: L, mask: syscall.ECHOKE},
"flusho": &bit{word: L, mask: syscall.FLUSHO},
"pendin": &bit{word: L, mask: syscall.PENDIN},
"iexten": &bit{word: L, mask: syscall.IEXTEN},
"isig": {word: L, mask: syscall.ISIG},
"icanon": {word: L, mask: syscall.ICANON},
"xcase": {word: L, mask: syscall.XCASE},
"echo": {word: L, mask: syscall.ECHO},
"echoe": {word: L, mask: syscall.ECHOE},
"echok": {word: L, mask: syscall.ECHOK},
"echonl": {word: L, mask: syscall.ECHONL},
"noflsh": {word: L, mask: syscall.NOFLSH},
"tostop": {word: L, mask: syscall.TOSTOP},
"echoctl": {word: L, mask: syscall.ECHOCTL},
"echoprt": {word: L, mask: syscall.ECHOPRT},
"echoke": {word: L, mask: syscall.ECHOKE},
"flusho": {word: L, mask: syscall.FLUSHO},
"pendin": {word: L, mask: syscall.PENDIN},
"iexten": {word: L, mask: syscall.IEXTEN},

//Controlprocessing

"cstopb": &bit{word: C, mask: syscall.CSTOPB},
"cread": &bit{word: C, mask: syscall.CREAD},
"parenb": &bit{word: C, mask: syscall.PARENB},
"parodd": &bit{word: C, mask: syscall.PARODD},
"hupcl": &bit{word: C, mask: syscall.HUPCL},
"clocal": &bit{word: C, mask: syscall.CLOCAL},
"cstopb": {word: C, mask: syscall.CSTOPB},
"cread": {word: C, mask: syscall.CREAD},
"parenb": {word: C, mask: syscall.PARENB},
"parodd": {word: C, mask: syscall.PARODD},
"hupcl": {word: C, mask: syscall.HUPCL},
"clocal": {word: C, mask: syscall.CLOCAL},
}
cc = map[string]int{
"min": 5,
Expand Down
Loading

0 comments on commit 2b17a7b

Please sign in to comment.