Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 2ec92e7

Browse files
author
Mattia Bertorello
committed
Fixed almost all the problem reported by golint
1 parent da074e2 commit 2ec92e7

28 files changed

+84
-83
lines changed

arduino/cores/packagemanager/package_manager.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (pm *PackageManager) ResolveFQBN(fqbn *cores.FQBN) (
162162
platformRelease := platform.GetInstalled()
163163
if platformRelease == nil {
164164
return targetPackage, nil, nil, nil, nil,
165-
fmt.Errorf("Platform %s is not installed", platformRelease)
165+
fmt.Errorf("platform %s is not installed", platformRelease)
166166
}
167167

168168
// Find board
@@ -210,31 +210,31 @@ func (pm *PackageManager) LoadPackageIndex(URL *url.URL) error {
210210

211211
// Package looks for the Package with the given name, returning a structure
212212
// able to perform further operations on that given resource
213-
func (pm *PackageManager) Package(name string) *packageActions {
213+
func (pm *PackageManager) Package(name string) *PackageActions {
214214
//TODO: perhaps these 2 structure should be merged? cores.Packages vs pkgmgr??
215215
var err error
216216
thePackage := pm.packages.Packages[name]
217217
if thePackage == nil {
218218
err = fmt.Errorf("package '%s' not found", name)
219219
}
220-
return &packageActions{
220+
return &PackageActions{
221221
aPackage: thePackage,
222222
forwardError: err,
223223
}
224224
}
225225

226226
// Actions that can be done on a Package
227227

228-
// packageActions defines what actions can be performed on the specific Package
228+
// PackageActions defines what actions can be performed on the specific Package
229229
// It serves as a status container for the fluent APIs
230-
type packageActions struct {
230+
type PackageActions struct {
231231
aPackage *cores.Package
232232
forwardError error
233233
}
234234

235235
// Tool looks for the Tool with the given name, returning a structure
236236
// able to perform further operations on that given resource
237-
func (pa *packageActions) Tool(name string) *toolActions {
237+
func (pa *PackageActions) Tool(name string) *ToolActions {
238238
var tool *cores.Tool
239239
err := pa.forwardError
240240
if err == nil {
@@ -244,7 +244,7 @@ func (pa *packageActions) Tool(name string) *toolActions {
244244
err = fmt.Errorf("tool '%s' not found in package '%s'", name, pa.aPackage.Name)
245245
}
246246
}
247-
return &toolActions{
247+
return &ToolActions{
248248
tool: tool,
249249
forwardError: err,
250250
}
@@ -254,15 +254,15 @@ func (pa *packageActions) Tool(name string) *toolActions {
254254

255255
// Actions that can be done on a Tool
256256

257-
// toolActions defines what actions can be performed on the specific Tool
257+
// ToolActions defines what actions can be performed on the specific Tool
258258
// It serves as a status container for the fluent APIs
259-
type toolActions struct {
259+
type ToolActions struct {
260260
tool *cores.Tool
261261
forwardError error
262262
}
263263

264264
// Get returns the final representation of the Tool
265-
func (ta *toolActions) Get() (*cores.Tool, error) {
265+
func (ta *ToolActions) Get() (*cores.Tool, error) {
266266
err := ta.forwardError
267267
if err == nil {
268268
return ta.tool, nil
@@ -271,7 +271,7 @@ func (ta *toolActions) Get() (*cores.Tool, error) {
271271
}
272272

273273
// IsInstalled checks whether any release of the Tool is installed in the system
274-
func (ta *toolActions) IsInstalled() (bool, error) {
274+
func (ta *ToolActions) IsInstalled() (bool, error) {
275275
if ta.forwardError != nil {
276276
return false, ta.forwardError
277277
}
@@ -284,27 +284,27 @@ func (ta *toolActions) IsInstalled() (bool, error) {
284284
return false, nil
285285
}
286286

287-
func (ta *toolActions) Release(version *semver.RelaxedVersion) *toolReleaseActions {
287+
func (ta *ToolActions) Release(version *semver.RelaxedVersion) *ToolReleaseActions {
288288
if ta.forwardError != nil {
289-
return &toolReleaseActions{forwardError: ta.forwardError}
289+
return &ToolReleaseActions{forwardError: ta.forwardError}
290290
}
291291
release := ta.tool.GetRelease(version)
292292
if release == nil {
293-
return &toolReleaseActions{forwardError: fmt.Errorf("release %s not found for tool %s", version, ta.tool.String())}
293+
return &ToolReleaseActions{forwardError: fmt.Errorf("release %s not found for tool %s", version, ta.tool.String())}
294294
}
295-
return &toolReleaseActions{release: release}
295+
return &ToolReleaseActions{release: release}
296296
}
297297

298298
// END -- Actions that can be done on a Tool
299299

300-
// toolReleaseActions defines what actions can be performed on the specific ToolRelease
300+
// ToolReleaseActions defines what actions can be performed on the specific ToolRelease
301301
// It serves as a status container for the fluent APIs
302-
type toolReleaseActions struct {
302+
type ToolReleaseActions struct {
303303
release *cores.ToolRelease
304304
forwardError error
305305
}
306306

307-
func (tr *toolReleaseActions) Get() (*cores.ToolRelease, error) {
307+
func (tr *ToolReleaseActions) Get() (*cores.ToolRelease, error) {
308308
if tr.forwardError != nil {
309309
return nil, tr.forwardError
310310
}

arduino/cores/status.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ func (targetPackage *Package) String() string {
113113
func (tdep ToolDependency) extractTool(sc Packages) (*Tool, error) {
114114
pkg, exists := sc.Packages[tdep.ToolPackager]
115115
if !exists {
116-
return nil, errors.New("Package not found")
116+
return nil, errors.New("package not found")
117117
}
118118
tool, exists := pkg.Tools[tdep.ToolName]
119119
if !exists {
120-
return nil, errors.New("Tool not found")
120+
return nil, errors.New("tool not found")
121121
}
122122
return tool, nil
123123
}
@@ -129,7 +129,7 @@ func (tdep ToolDependency) extractRelease(sc Packages) (*ToolRelease, error) {
129129
}
130130
release, exists := tool.Releases[tdep.ToolVersion.String()]
131131
if !exists {
132-
return nil, errors.New("Release Not Found")
132+
return nil, errors.New("release Not Found")
133133
}
134134
return release, nil
135135
}
@@ -143,15 +143,15 @@ func (packages *Packages) GetDepsOfPlatformRelease(release *PlatformRelease) ([]
143143
for _, dep := range release.Dependencies {
144144
pkg, exists := packages.Packages[dep.ToolPackager]
145145
if !exists {
146-
return nil, fmt.Errorf("Package %s not found", dep.ToolPackager)
146+
return nil, fmt.Errorf("package %s not found", dep.ToolPackager)
147147
}
148148
tool, exists := pkg.Tools[dep.ToolName]
149149
if !exists {
150-
return nil, fmt.Errorf("Tool %s not found", dep.ToolName)
150+
return nil, fmt.Errorf("tool %s not found", dep.ToolName)
151151
}
152152
toolRelease, exists := tool.Releases[dep.ToolVersion.String()]
153153
if !exists {
154-
return nil, fmt.Errorf("Tool version %s not found", dep.ToolVersion)
154+
return nil, fmt.Errorf("tool version %s not found", dep.ToolVersion)
155155
}
156156
ret = append(ret, toolRelease)
157157
}

arduino/cores/tools.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ func (tool *Tool) GetAllReleasesVersions() []*semver.RelaxedVersion {
8181

8282
// LatestRelease obtains latest version of a core package.
8383
func (tool *Tool) LatestRelease() *ToolRelease {
84-
if latest := tool.latestReleaseVersion(); latest == nil {
84+
latest := tool.latestReleaseVersion()
85+
if latest == nil {
8586
return nil
86-
} else {
87-
return tool.GetRelease(latest)
8887
}
88+
89+
return tool.GetRelease(latest)
8990
}
9091

9192
// latestReleaseVersion obtains latest version number.

arduino/resources/helpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ func (r *DownloadResource) IsCached(downloadDir *paths.Path) (bool, error) {
4141
if err != nil {
4242
return false, fmt.Errorf("getting archive path: %s", err)
4343
}
44-
45-
if exist, err := archivePath.Exist(); err != nil {
44+
exist, err := archivePath.Exist()
45+
if err != nil {
4646
return false, fmt.Errorf("checking archive existence: %s", err)
47-
} else {
48-
return exist, nil
4947
}
48+
49+
return exist, nil
5050
}
5151

5252
// Download a DownloadResource.

arduino/resources/install.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ func (release *DownloadResource) Install(downloadDir, tempPath, destDir *paths.P
9696

9797
// IsDirEmpty returns true if the directory specified by path is empty.
9898
func IsDirEmpty(path *paths.Path) (bool, error) {
99-
if files, err := path.ReadDir(); err != nil {
99+
files, err := path.ReadDir()
100+
if err != nil {
100101
return false, err
101-
} else {
102-
return len(files) == 0, nil
103102
}
103+
return len(files) == 0, nil
104104
}
105105

106106
func findPackageRoot(parent *paths.Path) (*paths.Path, error) {

builder_client_helpers/alive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"

builder_client_helpers/boards.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"

builder_client_helpers/boards_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"

builder_client_helpers/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"github.com/goadesign/goa"

builder_client_helpers/compilations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"bytes"

builder_client_helpers/examples.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"
@@ -30,16 +30,16 @@ func ListExamplesPath() string {
3030
}
3131

3232
// ListExamples provides a list of all the builtin examples
33-
func (c *Client) ListExamples(ctx context.Context, path string, maintainer *string, type_ *string) (*http.Response, error) {
34-
req, err := c.NewListExamplesRequest(ctx, path, maintainer, type_)
33+
func (c *Client) ListExamples(ctx context.Context, path string, maintainer *string, type1 *string) (*http.Response, error) {
34+
req, err := c.NewListExamplesRequest(ctx, path, maintainer, type1)
3535
if err != nil {
3636
return nil, err
3737
}
3838
return c.Client.Do(ctx, req)
3939
}
4040

4141
// NewListExamplesRequest create the request corresponding to the list action endpoint of the examples resource.
42-
func (c *Client) NewListExamplesRequest(ctx context.Context, path string, maintainer *string, type_ *string) (*http.Request, error) {
42+
func (c *Client) NewListExamplesRequest(ctx context.Context, path string, maintainer *string, type1 *string) (*http.Request, error) {
4343
scheme := c.Scheme
4444
if scheme == "" {
4545
scheme = "http"
@@ -49,8 +49,8 @@ func (c *Client) NewListExamplesRequest(ctx context.Context, path string, mainta
4949
if maintainer != nil {
5050
values.Set("maintainer", *maintainer)
5151
}
52-
if type_ != nil {
53-
values.Set("type", *type_)
52+
if type1 != nil {
53+
values.Set("type", *type1)
5454
}
5555
u.RawQuery = values.Encode()
5656
req, err := http.NewRequest("GET", u.String(), nil)

builder_client_helpers/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"

builder_client_helpers/libraries.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"
@@ -30,16 +30,16 @@ func ListLibrariesPath() string {
3030
}
3131

3232
// ListLibraries provides a list of all the latest versions of the libraries supported by Arduino Create. Doesn't require any authentication.
33-
func (c *Client) ListLibraries(ctx context.Context, path string, maintainer *string, type_ *string, withoutType *string) (*http.Response, error) {
34-
req, err := c.NewListLibrariesRequest(ctx, path, maintainer, type_, withoutType)
33+
func (c *Client) ListLibraries(ctx context.Context, path string, maintainer *string, type1 *string, withoutType *string) (*http.Response, error) {
34+
req, err := c.NewListLibrariesRequest(ctx, path, maintainer, type1, withoutType)
3535
if err != nil {
3636
return nil, err
3737
}
3838
return c.Client.Do(ctx, req)
3939
}
4040

4141
// NewListLibrariesRequest create the request corresponding to the list action endpoint of the libraries resource.
42-
func (c *Client) NewListLibrariesRequest(ctx context.Context, path string, maintainer *string, type_ *string, withoutType *string) (*http.Request, error) {
42+
func (c *Client) NewListLibrariesRequest(ctx context.Context, path string, maintainer *string, type1 *string, withoutType *string) (*http.Request, error) {
4343
scheme := c.Scheme
4444
if scheme == "" {
4545
scheme = "http"
@@ -49,8 +49,8 @@ func (c *Client) NewListLibrariesRequest(ctx context.Context, path string, maint
4949
if maintainer != nil {
5050
values.Set("maintainer", *maintainer)
5151
}
52-
if type_ != nil {
53-
values.Set("type", *type_)
52+
if type1 != nil {
53+
values.Set("type", *type1)
5454
}
5555
if withoutType != nil {
5656
values.Set("without_type", *withoutType)

builder_client_helpers/media_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"net/http"

builder_client_helpers/pinned_libraries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"context"

builder_client_helpers/public.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
/*
2121
import (

builder_client_helpers/user_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
package builderClient
18+
package builderclient
1919

2020
import (
2121
"github.com/goadesign/goa"

commands/commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535

3636
// Redirecting stdOut so we can analyze output line by
3737
// line and check with what we want.
38-
var stdOut *os.File = os.Stdout
38+
var stdOut = os.Stdout // *os.File
3939

4040
type stdOutRedirect struct {
4141
tempFile *os.File

0 commit comments

Comments
 (0)