Skip to content

Commit a83f6d9

Browse files
committed
Follow standard Golang naming conventions
As mandated by golint.
1 parent f07b211 commit a83f6d9

10 files changed

+47
-47
lines changed

libraries/bad_file_cleaner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ func FailIfHasUndesiredFiles(folder string) error {
1515
return failIfContainsExes(folder)
1616
}
1717

18-
var FORBIDDEN_FILES = []string{".development"}
18+
var ForbiddenFiles = []string{".development"}
1919

2020
func failIfContainsForbiddenFileInRoot(folder string) error {
21-
for _, file := range FORBIDDEN_FILES {
21+
for _, file := range ForbiddenFiles {
2222
if _, err := os.Stat(filepath.Join(folder, file)); err == nil {
2323
return errors.New(file + " file found, skipping")
2424
}
@@ -27,10 +27,10 @@ func failIfContainsForbiddenFileInRoot(folder string) error {
2727
return nil
2828
}
2929

30-
var PATTERNS = []string{"*.exe"}
30+
var Patterns = []string{"*.exe"}
3131

3232
func failIfContainsExes(folder string) error {
33-
for _, pattern := range PATTERNS {
33+
for _, pattern := range Patterns {
3434
cmd := exec.Command("find", folder, "-type", "f", "-name", pattern)
3535
output, err := cmd.CombinedOutput()
3636
if err != nil {

libraries/github_release_downloader.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import (
99
"strings"
1010
)
1111

12-
func GithubDownloadRelease(repoUrl, version string) (string, int64, string, error) {
12+
func GithubDownloadRelease(repoURL, version string) (string, int64, string, error) {
1313
tempfile, err := ioutil.TempFile("", "github")
1414
if err != nil {
1515
return "", -1, "", err
1616
}
1717
defer os.Remove(tempfile.Name())
1818

19-
zipFileUrl := strings.Replace(repoUrl, ".git", "", 1) + "/archive/" + version + ".zip"
19+
zipFileURL := strings.Replace(repoURL, ".git", "", 1) + "/archive/" + version + ".zip"
2020

21-
err = saveUrlIn(zipFileUrl, tempfile)
21+
err = saveURLIn(zipFileURL, tempfile)
2222
if err != nil {
2323
return "", -1, "", err
2424
}
@@ -34,10 +34,10 @@ func GithubDownloadRelease(repoUrl, version string) (string, int64, string, erro
3434
return "", -1, "", err
3535
}
3636

37-
return zipFileUrl, size, checksum, nil
37+
return zipFileURL, size, checksum, nil
3838
}
3939

40-
func saveUrlIn(url string, tempfile *os.File) error {
40+
func saveURLIn(url string, tempfile *os.File) error {
4141
resp, err := http.Get(url)
4242
if err != nil {
4343
return err

libraries/repoarchive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func ZipRepo(repoFolder string, baseFolder string, zipFolderName string) (string
1515
return "", err
1616
}
1717
absoluteFileName := filepath.Join(baseFolder, zipFolderName+".zip")
18-
if err := zip.ZipDirectory(repoFolder, zipFolderName, absoluteFileName); err != nil {
18+
if err := zip.Directory(repoFolder, zipFolderName, absoluteFileName); err != nil {
1919
os.Remove(absoluteFileName)
2020
return "", err
2121
}

libraries/repoclone.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ type Repository struct {
2525
func CloneOrFetch(repoMeta *Repo, folderName string) (*Repository, error) {
2626
repo := Repository{
2727
FolderPath: folderName,
28-
URL: repoMeta.Url,
28+
URL: repoMeta.URL,
2929
}
3030

3131
if _, err := os.Stat(folderName); os.IsNotExist(err) {
32-
repo.Repository, err = git.PlainClone(folderName, false, &git.CloneOptions{URL: repoMeta.Url})
32+
repo.Repository, err = git.PlainClone(folderName, false, &git.CloneOptions{URL: repoMeta.URL})
3333
if err != nil {
3434
return nil, err
3535
}

libraries/repoclone_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func TestCloneRepos(t *testing.T) {
12-
meta := &Repo{Url: "https://github.com/arduino-libraries/Servo.git"}
12+
meta := &Repo{URL: "https://github.com/arduino-libraries/Servo.git"}
1313

1414
subfolder, err := meta.AsFolder()
1515
require.NoError(t, err)

libraries/repolist.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func loadRepoListFromFile(filename string) ([]*Repo, error) {
3030
types := strings.Split(split[1], ",")
3131
name := split[2]
3232
repos = append(repos, &Repo{
33-
Url: url,
33+
URL: url,
3434
Types: types,
3535
LibraryName: name,
3636
})
@@ -46,7 +46,7 @@ type repoMatcher interface {
4646

4747
type repoMatcherIfDotGit struct{}
4848

49-
func (_ repoMatcherIfDotGit) Match(url string) bool {
49+
func (repoMatcherIfDotGit) Match(url string) bool {
5050
return strings.Index(url, "https://") == 0 && strings.LastIndex(url, ".git") == len(url)-len(".git")
5151
}
5252

@@ -69,7 +69,7 @@ type GitURLsError struct {
6969
}
7070

7171
type Repo struct {
72-
Url string
72+
URL string
7373
Types []string
7474
LibraryName string
7575
}
@@ -78,7 +78,7 @@ type Repo struct {
7878
// For example if the repo URL is https://github.com/example/lib.git this function
7979
// will return "github.com/example/lib"
8080
func (repo *Repo) AsFolder() (string, error) {
81-
u, err := url.Parse(repo.Url)
81+
u, err := url.Parse(repo.URL)
8282
if err != nil {
8383
return "", err
8484
}
@@ -87,24 +87,24 @@ func (repo *Repo) AsFolder() (string, error) {
8787
return folderName, nil
8888
}
8989

90-
type ReposByUrl []*Repo
90+
type ReposByURL []*Repo
9191

92-
func (r ReposByUrl) Len() int {
92+
func (r ReposByURL) Len() int {
9393
return len(r)
9494
}
9595

96-
func (r ReposByUrl) Swap(i, j int) {
96+
func (r ReposByURL) Swap(i, j int) {
9797
r[i], r[j] = r[j], r[i]
9898
}
9999

100-
func (r ReposByUrl) Less(i, j int) bool {
101-
return r[i].Url < r[j].Url
100+
func (r ReposByURL) Less(i, j int) bool {
101+
return r[i].URL < r[j].URL
102102
}
103103

104104
func (err GitURLsError) Error() string {
105105
error := bytes.NewBufferString("Following URL are unknown or unsupported git repos:\n")
106106
for _, v := range err.Repos {
107-
fmt.Fprintln(error, v.Url)
107+
fmt.Fprintln(error, v.URL)
108108
}
109109

110110
return error.String()
@@ -114,7 +114,7 @@ func filterReposBy(repos []*Repo, matcher repoMatcher) ([]*Repo, error) {
114114
var filtered []*Repo
115115
var wrong []*Repo
116116
for _, repo := range repos {
117-
if matcher.Match(repo.Url) {
117+
if matcher.Match(repo.URL) {
118118
filtered = append(filtered, repo)
119119
} else {
120120
wrong = append(wrong, repo)
@@ -171,9 +171,9 @@ func toListOfUniqueRepos(repos []*Repo) []*Repo {
171171
var finalRepos []*Repo
172172

173173
for _, repo := range repos {
174-
if _, contains := repoMap[repo.Url]; !contains {
174+
if _, contains := repoMap[repo.URL]; !contains {
175175
finalRepos = append(finalRepos, repo)
176-
repoMap[repo.Url] = repo
176+
repoMap[repo.URL] = repo
177177
}
178178
}
179179

libraries/repolist_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ func TestListRepos(t *testing.T) {
1111

1212
require.Equal(t, 11, len(repos))
1313

14-
require.Equal(t, "https://github.com/PaulStoffregen/OctoWS2811.git", repos[0].Url)
15-
require.Equal(t, "https://github.com/PaulStoffregen/AltSoftSerial.git", repos[1].Url)
16-
17-
require.Equal(t, "https://github.com/Cheong2K/ble-sdk-arduino.git", repos[2].Url)
18-
require.Equal(t, "https://github.com/arduino-libraries/Bridge.git", repos[3].Url)
19-
require.Equal(t, "https://github.com/adafruit/Adafruit_ADS1X15.git", repos[4].Url)
20-
require.Equal(t, "https://github.com/adafruit/Adafruit_ADXL345.git", repos[5].Url)
21-
require.Equal(t, "https://github.com/adafruit/Adafruit_AHRS.git", repos[6].Url)
22-
require.Equal(t, "https://github.com/adafruit/Adafruit_AM2315.git", repos[7].Url)
23-
require.Equal(t, "https://github.com/arduino-libraries/Scheduler.git", repos[8].Url)
24-
require.Equal(t, "https://github.com/arduino-libraries/SD.git", repos[9].Url)
25-
require.Equal(t, "https://github.com/arduino-libraries/Servo.git", repos[10].Url)
14+
require.Equal(t, "https://github.com/PaulStoffregen/OctoWS2811.git", repos[0].URL)
15+
require.Equal(t, "https://github.com/PaulStoffregen/AltSoftSerial.git", repos[1].URL)
16+
17+
require.Equal(t, "https://github.com/Cheong2K/ble-sdk-arduino.git", repos[2].URL)
18+
require.Equal(t, "https://github.com/arduino-libraries/Bridge.git", repos[3].URL)
19+
require.Equal(t, "https://github.com/adafruit/Adafruit_ADS1X15.git", repos[4].URL)
20+
require.Equal(t, "https://github.com/adafruit/Adafruit_ADXL345.git", repos[5].URL)
21+
require.Equal(t, "https://github.com/adafruit/Adafruit_AHRS.git", repos[6].URL)
22+
require.Equal(t, "https://github.com/adafruit/Adafruit_AM2315.git", repos[7].URL)
23+
require.Equal(t, "https://github.com/arduino-libraries/Scheduler.git", repos[8].URL)
24+
require.Equal(t, "https://github.com/arduino-libraries/SD.git", repos[9].URL)
25+
require.Equal(t, "https://github.com/arduino-libraries/Servo.git", repos[10].URL)
2626
require.Error(t, err)
2727

2828
error, ok := err.(GitURLsError)
2929
require.True(t, ok)
30-
require.Equal(t, "https://github.com/arduino-libraries", error.Repos[0].Url)
31-
require.Equal(t, "git@github.com:PaulStoffregen/Audio.git", error.Repos[1].Url)
30+
require.Equal(t, "https://github.com/arduino-libraries", error.Repos[0].URL)
31+
require.Equal(t, "git@github.com:PaulStoffregen/Audio.git", error.Repos[1].URL)
3232
}
3333

3434
func TestRepoFolderPathDetermination(t *testing.T) {
35-
repo := &Repo{Url: "https://github.com/arduino-libraries/Servo.git"}
35+
repo := &Repo{URL: "https://github.com/arduino-libraries/Servo.git"}
3636
f, err := repo.AsFolder()
3737
require.NoError(t, err)
3838
require.Equal(t, "github.com/arduino-libraries/Servo", f)
3939

40-
repo = &Repo{Url: "https://bitbucket.org/bjoern/arduino_osc"}
40+
repo = &Repo{URL: "https://bitbucket.org/bjoern/arduino_osc"}
4141
f, err = repo.AsFolder()
4242
require.NoError(t, err)
4343
require.Equal(t, "bitbucket.org/bjoern/arduino_osc", f)

libraries/zip/ziphelper.go

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

1313
// ZipDirectory creates a new zip archive that contains a copy of "rootFolder" into "zipFile".
1414
// Inside the archive "rootFolder" will be renamed to "zipRootFolderName".
15-
func ZipDirectory(rootFolder string, zipRootFolderName string, zipFile string) error {
15+
func Directory(rootFolder string, zipRootFolderName string, zipFile string) error {
1616
checks := func(path string, info os.FileInfo, err error) error {
1717
info, err = os.Lstat(path)
1818
if err != nil {

libraries/zip/ziphelper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestZip(t *testing.T) {
1818
require.NoError(t, os.Remove(zipFileName))
1919
defer os.RemoveAll(zipFileName)
2020

21-
err = ZipDirectory("./testzip", "a_zip", zipFileName)
21+
err = Directory("./testzip", "a_zip", zipFileName)
2222
require.NoError(t, err)
2323

2424
zipFileReader, err := zip.OpenReader(zipFileName)

sync_libraries.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
type Config struct {
21-
BaseDownloadUrl string
21+
BaseDownloadURL string
2222
LibrariesFolder string
2323
LogsFolder string
2424
LibrariesDB string
@@ -179,7 +179,7 @@ func setup(config *Config) {
179179
}
180180

181181
func syncLibrary(logger *log.Logger, repoMetadata *libraries.Repo, libraryDb *db.DB) {
182-
logger.Printf("Scraping %s", repoMetadata.Url)
182+
logger.Printf("Scraping %s", repoMetadata.URL)
183183

184184
repoFolderName, err := repoMetadata.AsFolder()
185185
if err != nil {
@@ -282,7 +282,7 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
282282
return fmt.Errorf("Error while calculating checksums: %s", err)
283283
}
284284
release := db.FromLibraryToRelease(library)
285-
release.URL = config.BaseDownloadUrl + host + "/" + lib + "/" + zipName + ".zip"
285+
release.URL = config.BaseDownloadURL + host + "/" + lib + "/" + zipName + ".zip"
286286
release.ArchiveFileName = zipName + ".zip"
287287
release.Size = size
288288
release.Checksum = checksum

0 commit comments

Comments
 (0)