From c3211c6a14f56c3f77f710f4c131f5d972104975 Mon Sep 17 00:00:00 2001 From: akuma06 Date: Thu, 25 May 2017 23:35:37 +0200 Subject: [PATCH] Gofmt friendly (#752) Keeping Go source code in line with what they preconize --- config/torrents.go | 2 +- model/file.go | 1 - model/torrent.go | 10 ++++----- service/torrent/torrent.go | 8 +++---- util/filelist/filelist.go | 39 +++++++++++++++++----------------- util/filelist/filelist_test.go | 19 ++++++++--------- 6 files changed, 38 insertions(+), 41 deletions(-) diff --git a/config/torrents.go b/config/torrents.go index 68368dee..2dcac2dd 100644 --- a/config/torrents.go +++ b/config/torrents.go @@ -47,4 +47,4 @@ var TorrentCleanCategories = map[string]string{ "1_": "software", "1_1": "software_applications", "1_2": "software_games", -} \ No newline at end of file +} diff --git a/model/file.go b/model/file.go index ecef4db8..7dc4a9fe 100644 --- a/model/file.go +++ b/model/file.go @@ -41,4 +41,3 @@ func (f *File) Filename() string { path := f.Path() return path[len(path)-1] } - diff --git a/model/torrent.go b/model/torrent.go index e86daa28..089d3d0b 100644 --- a/model/torrent.go +++ b/model/torrent.go @@ -14,11 +14,11 @@ import ( ) const ( - TorrentStatusNormal = 1 - TorrentStatusRemake = 2 - TorrentStatusTrusted = 3 - TorrentStatusAPlus = 4 - TorrentStatusBlocked = 5 + TorrentStatusNormal = 1 + TorrentStatusRemake = 2 + TorrentStatusTrusted = 3 + TorrentStatusAPlus = 4 + TorrentStatusBlocked = 5 ) type Feed struct { diff --git a/service/torrent/torrent.go b/service/torrent/torrent.go index 85317094..bff14fa0 100644 --- a/service/torrent/torrent.go +++ b/service/torrent/torrent.go @@ -130,9 +130,9 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim if !deleted { conditionArray = append(conditionArray, "deleted_at IS NULL") } else { - conditionArray = append(conditionArray, "deleted_at NOT NULL") + conditionArray = append(conditionArray, "deleted_at NOT NULL") } - + conditions := strings.Join(conditionArray, " AND ") if countAll { @@ -225,7 +225,7 @@ func ToggleBlockTorrent(id string) (model.Torrent, int, error) { if torrent.Status == model.TorrentStatusBlocked { torrent.Status = model.TorrentStatusNormal } else { - torrent.Status = model.TorrentStatusBlocked + torrent.Status = model.TorrentStatusBlocked } if db.ORM.Unscoped().Model(&torrent).UpdateColumn(&torrent).Error != nil { return torrent, http.StatusInternalServerError, errors.New("Torrent was not updated.") @@ -244,4 +244,4 @@ func UpdateTorrent(torrent model.Torrent) (int, error) { func GetDeletedTorrents(parameters *serviceBase.WhereParams, orderBy string, limit int, offset int) (torrents []model.Torrent, count int, err error) { torrents, count, err = getTorrentsOrderBy(parameters, orderBy, limit, offset, true, true, true) return -} \ No newline at end of file +} diff --git a/util/filelist/filelist.go b/util/filelist/filelist.go index 27db4d4c..0b0697b1 100644 --- a/util/filelist/filelist.go +++ b/util/filelist/filelist.go @@ -1,17 +1,17 @@ -package filelist; +package filelist import ( - "github.com/bradfitz/slice" - "github.com/NyaaPantsu/nyaa/model" - "html/template" "bytes" - "strings" + "github.com/NyaaPantsu/nyaa/model" + "github.com/bradfitz/slice" + "html/template" "strconv" + "strings" ) type FileListFolder struct { Folders map[string]*FileListFolder - Files []model.File + Files []model.File } func FileListToFolder(fileList []model.File) (out *FileListFolder) { @@ -27,10 +27,10 @@ func FileListToFolder(fileList []model.File) (out *FileListFolder) { if len(pathArray) > 1 { pathStrippedFile := model.File{ - ID: file.ID, - TorrentID: file.TorrentID, + ID: file.ID, + TorrentID: file.TorrentID, BencodedPath: "", - Filesize: file.Filesize, + Filesize: file.Filesize, } pathStrippedFile.SetPath(pathArray[1:]) pathsToFolders[pathArray[0]] = append(pathsToFolders[pathArray[0]], pathStrippedFile) @@ -59,19 +59,19 @@ func (f *FileListFolder) TotalSize() (out int64) { } type folderFormatData struct { - Data interface{} - FolderName string - TotalSize int64 - NestLevel uint + Data interface{} + FolderName string + TotalSize int64 + NestLevel uint ParentIdentifier string - Identifier string + Identifier string } type fileFormatData struct { - Data interface{} - Filename string - Filesize int64 - NestLevel uint + Data interface{} + Filename string + Filesize int64 + NestLevel uint ParentIdentifier string } @@ -107,7 +107,7 @@ func (f *FileListFolder) makeFolderTreeView(folderTmpl *template.Template, fileT } output += tmp - tmp, err = folder.makeFolderTreeView(folderTmpl, fileTmpl, nestLevel + 1, childIdentifier, data) + tmp, err = folder.makeFolderTreeView(folderTmpl, fileTmpl, nestLevel+1, childIdentifier, data) if err != nil { return } @@ -141,4 +141,3 @@ func (f *FileListFolder) MakeFolderTreeView(folderFormat string, fileFormat stri output, err = f.makeFolderTreeView(folderTmpl, fileTmpl, 0, "root", data) return } - diff --git a/util/filelist/filelist_test.go b/util/filelist/filelist_test.go index be81a79d..6f3f724a 100644 --- a/util/filelist/filelist_test.go +++ b/util/filelist/filelist_test.go @@ -1,9 +1,9 @@ -package filelist; +package filelist import ( - "testing" - "html/template" "github.com/NyaaPantsu/nyaa/model" + "html/template" + "testing" ) func makeDummyFile(path ...string) (file model.File) { @@ -25,12 +25,12 @@ func TestFilelist(T *testing.T) { makeDummyFile("A", "C", "C.txt"), makeDummyFile("B.txt"), } - expected := "A\n"+ - "-B\n"+ - "--C.txt\n"+ - "-C\n"+ - "--C.txt\n"+ - "B.txt\n" + expected := "A\n" + + "-B\n" + + "--C.txt\n" + + "-C\n" + + "--C.txt\n" + + "B.txt\n" filelist := FileListToFolder(files) @@ -46,4 +46,3 @@ func TestFilelist(T *testing.T) { return } } -