Skip to content

Commit 12b6353

Browse files
committed
Apply gofmt on all files
1 parent 41041ce commit 12b6353

File tree

8 files changed

+69
-71
lines changed

8 files changed

+69
-71
lines changed

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/bossac/bossac.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@ package bossac
22

33
import (
44
"bytes"
5-
"errors"
6-
"path/filepath"
7-
"log"
8-
"os/exec"
9-
"io/ioutil"
5+
"errors"
106
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
11-
serial "go.bug.st/serial.v1"
7+
serial "go.bug.st/serial.v1"
8+
"io/ioutil"
9+
"log"
10+
"os/exec"
11+
"path/filepath"
1212
//"go.bug.st/serial.v1/enumerator"
13-
"time"
13+
"time"
1414
)
1515

1616
type Bossac struct {
1717
}
1818

1919
func (b *Bossac) Flash(ctx context.Context, filename string) error {
20-
log.Println("Flashing " + filename)
20+
log.Println("Flashing " + filename)
2121

22-
port, err := reset(ctx.PortName, true)
23-
if err != nil {
24-
return err
25-
}
26-
err = invokeBossac([]string{ctx.ProgrammerPath, "-e", "-R", "-p", port, "-w" , filename})
22+
port, err := reset(ctx.PortName, true)
23+
if err != nil {
24+
return err
25+
}
26+
err = invokeBossac([]string{ctx.ProgrammerPath, "-e", "-R", "-p", port, "-w", filename})
2727

28-
ports, err := serial.GetPortsList()
29-
port = waitReset(ports, port)
28+
ports, err := serial.GetPortsList()
29+
port = waitReset(ports, port)
3030

31-
return err
31+
return err
3232
}
3333

34-
func (b *Bossac)DumpAndFlash(ctx context.Context, filename string) (string, error) {
35-
log.Println("Flashing " + filename)
36-
dir, err := ioutil.TempDir("", "wifiFlasher_dump")
37-
port, err := reset(ctx.PortName, true)
38-
if err != nil {
39-
return "", err
40-
}
34+
func (b *Bossac) DumpAndFlash(ctx context.Context, filename string) (string, error) {
35+
log.Println("Flashing " + filename)
36+
dir, err := ioutil.TempDir("", "wifiFlasher_dump")
37+
port, err := reset(ctx.PortName, true)
38+
if err != nil {
39+
return "", err
40+
}
4141
err = invokeBossac([]string{ctx.ProgrammerPath, "-u", "-r", "-p", port, filepath.Join(dir, "dump.bin")})
4242
log.Println("Original sketch saved at " + filepath.Join(dir, "dump.bin"))
4343
if err != nil {
4444
return "", err
4545
}
46-
err = invokeBossac([]string{ctx.ProgrammerPath, "-e", "-R", "-p", port, "-w" , filename})
46+
err = invokeBossac([]string{ctx.ProgrammerPath, "-e", "-R", "-p", port, "-w", filename})
4747

48-
ports, err := serial.GetPortsList()
49-
port = waitReset(ports, port)
48+
ports, err := serial.GetPortsList()
49+
port = waitReset(ports, port)
5050

51-
return filepath.Join(dir, "dump.bin"), err
51+
return filepath.Join(dir, "dump.bin"), err
5252
}
5353

5454
func invokeBossac(args []string) error {
55-
cmd := exec.Command(args[0], args[1:]...)
56-
var out bytes.Buffer
55+
cmd := exec.Command(args[0], args[1:]...)
56+
var out bytes.Buffer
5757
cmd.Stdout = &out
5858
err := cmd.Run()
59-
log.Println(out.String())
59+
log.Println(out.String())
6060
return err
6161
}
6262

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/cli/main/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
"flag"
5-
"log"
6-
"strings"
5+
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
76
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/nina"
87
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/winc"
9-
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
8+
"log"
9+
"strings"
1010
)
1111

1212
var ctx context.Context

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/context/context.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ func (af *addressFlags) Set(value string) error {
1616
}
1717

1818
type Context struct {
19-
PortName string
20-
RootCertDir string
21-
Addresses addressFlags
22-
FirmwareFile string
19+
PortName string
20+
RootCertDir string
21+
Addresses addressFlags
22+
FirmwareFile string
2323
FWUploaderBinary string
24-
ReadAll bool
25-
BinaryToRestore string
26-
ProgrammerPath string
27-
Model string
24+
ReadAll bool
25+
BinaryToRestore string
26+
ProgrammerPath string
27+
Model string
2828
}
2929

3030
type Programmer interface {
31-
DumpAndFlash(ctx Context, filename string) (string, error)
31+
DumpAndFlash(ctx Context, filename string) (string, error)
3232
Flash(ctx Context, filename string) error
3333
}

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/nina/certificates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ package nina
2121
import (
2222
"crypto/tls"
2323
"crypto/x509"
24+
"encoding/pem"
2425
"errors"
2526
"io/ioutil"
2627
"log"
2728
"path"
2829
"path/filepath"
29-
"encoding/pem"
3030
)
3131

3232
type CertEntry []byte

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/nina/flasher.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
package nina
2121

2222
import (
23+
"crypto/md5"
2324
"encoding/binary"
24-
"time"
2525
"log"
26-
"crypto/md5"
26+
"time"
2727

2828
serial "github.com/facchinm/go-serial"
2929
)
@@ -196,7 +196,7 @@ func (flasher *Flasher) sendCommand(command byte, address uint32, val uint32, pa
196196

197197
func (flasher *Flasher) Md5sum(data []byte) error {
198198
hasher := md5.New()
199-
hasher.Write(data)
199+
hasher.Write(data)
200200

201201
log.Println("Checking firmware integrity")
202202

@@ -223,11 +223,11 @@ func (flasher *Flasher) Md5sum(data []byte) error {
223223
md5sumfromdevice := hasher.Sum(nil)
224224

225225
i := 0
226-
for (i<16) {
226+
for i < 16 {
227227
if md5sumfromdevice[i] != md5sum[i] {
228-
return &FlasherError{err: "MD5sum failed"}
229-
}
230-
i++
228+
return &FlasherError{err: "MD5sum failed"}
229+
}
230+
i++
231231
}
232232

233233
log.Println("Integrity ok")
@@ -239,7 +239,7 @@ func OpenSerial(portName string) (serial.Port, error) {
239239
mode := &serial.Mode{
240240
BaudRate: 230400,
241241
Vtimeout: 100,
242-
Vmin: 0,
242+
Vmin: 0,
243243
}
244244

245245
return serial.Open(portName, mode)

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/nina/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
package nina
2121

2222
import (
23+
"fmt"
24+
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/bossac"
25+
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
2326
"io/ioutil"
2427
"log"
25-
"fmt"
2628
"os"
27-
"strings"
28-
"strconv"
2929
"path/filepath"
30-
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
31-
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/bossac"
30+
"strconv"
31+
"strings"
3232
//"github.com/arduino-libraries/WiFi101-FirmwareUpdater/avrdude"
3333
)
3434

@@ -52,7 +52,7 @@ func Run(ctx context.Context) {
5252
err = programmer.Flash(ctx, ctx.FWUploaderBinary)
5353
}
5454
if err != nil {
55-
log.Fatal(err)
55+
log.Fatal(err)
5656
}
5757
}
5858

@@ -101,11 +101,11 @@ func Run(ctx context.Context) {
101101
}
102102
}
103103

104-
if (ctx.BinaryToRestore != "") {
104+
if ctx.BinaryToRestore != "" {
105105
log.Println("Restoring previous sketch")
106106
f.Close()
107107

108-
if err := programmer.Flash(ctx, ctx.BinaryToRestore) ; err != nil {
108+
if err := programmer.Flash(ctx, ctx.BinaryToRestore); err != nil {
109109
log.Fatal(err)
110110
}
111111

@@ -142,7 +142,7 @@ func flashCerts(ctx context.Context) error {
142142
}
143143

144144
// pad certificatesData to flash page
145-
for len(certificatesData) % int(payloadSize) != 0 {
145+
for len(certificatesData)%int(payloadSize) != 0 {
146146
certificatesData = append(certificatesData, 0)
147147
}
148148

@@ -186,7 +186,7 @@ func flashChunk(offset int, buffer []byte, doChecksum bool) error {
186186

187187
fmt.Println("")
188188

189-
if (doChecksum) {
189+
if doChecksum {
190190
return f.Md5sum(buffer)
191191
} else {
192192
return nil

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/winc/flasher.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ package winc
2121

2222
import (
2323
"encoding/binary"
24-
"log"
2524
serial "github.com/facchinm/go-serial"
25+
"log"
2626
"time"
2727
)
2828

@@ -192,13 +192,11 @@ func (flasher *Flasher) sendCommand(command byte, address uint32, val uint32, pa
192192
return nil
193193
}
194194

195-
196-
197195
func OpenSerial(portName string) (serial.Port, error) {
198196
mode := &serial.Mode{
199197
BaudRate: 1000000,
200198
Vtimeout: 100,
201-
Vmin: 0,
199+
Vmin: 0,
202200
}
203201

204202
return serial.Open(portName, mode)

src/github.com/arduino-libraries/WiFi101-FirmwareUpdater/winc/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ package winc
2222
import (
2323
"bytes"
2424
"errors"
25+
"fmt"
26+
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/bossac"
27+
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
2528
"io/ioutil"
2629
"log"
27-
"fmt"
2830
"os"
2931
"strconv"
30-
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/context"
31-
"github.com/arduino-libraries/WiFi101-FirmwareUpdater/bossac"
3232
)
3333

3434
var f *Flasher
@@ -48,7 +48,7 @@ func Run(ctx context.Context) {
4848
err = programmer.Flash(ctx, ctx.FWUploaderBinary)
4949
}
5050
if err != nil {
51-
log.Fatal(err)
51+
log.Fatal(err)
5252
}
5353
}
5454

@@ -97,11 +97,11 @@ func Run(ctx context.Context) {
9797
}
9898
}
9999

100-
if (ctx.BinaryToRestore != "") {
100+
if ctx.BinaryToRestore != "" {
101101
log.Println("Restoring previous sketch")
102102
f.Close()
103103

104-
if err := programmer.Flash(ctx, ctx.BinaryToRestore) ; err != nil {
104+
if err := programmer.Flash(ctx, ctx.BinaryToRestore); err != nil {
105105
log.Fatal(err)
106106
}
107107

0 commit comments

Comments
 (0)