diff --git a/Makefile b/Makefile index d9dcffd63..4a2601eb0 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ GORUN=$(GOCMD) run GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test GOGET=$(GOCMD) get +GOFMT=$(GOCMD) fmt BINARY_NAME=photoprism all: deps js build @@ -28,6 +29,8 @@ clean: image: docker build . --tag photoprism/photoprism docker push photoprism/photoprism +format: + $(GOFMT) ./... deps: $(GOBUILD) -v ./... upgrade: diff --git a/cmd/photoprism/photoprism.go b/cmd/photoprism/photoprism.go index 58e23ad41..b39efe9ec 100644 --- a/cmd/photoprism/photoprism.go +++ b/cmd/photoprism/photoprism.go @@ -2,11 +2,11 @@ package main import ( "fmt" + "github.com/araddon/dateparse" "github.com/photoprism/photoprism" + "github.com/photoprism/photoprism/server" "github.com/urfave/cli" "os" - "github.com/araddon/dateparse" - "github.com/photoprism/photoprism/server" ) func main() { @@ -251,7 +251,7 @@ func main() { } } - exportPath := fmt.Sprintf("%s/%s", conf.ExportPath, name); + exportPath := fmt.Sprintf("%s/%s", conf.ExportPath, name) size := context.Int("size") originals := photoprism.FindOriginalsByDate(conf.OriginalsPath, afterDate, beforeDate) diff --git a/go.mod b/go.mod index c8931aef6..db9275df2 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/pkg/errors v0.8.0 github.com/pmezard/go-difflib v1.0.0 github.com/rwcarlsen/goexif v0.0.0-20180518182100-8d986c03457a - github.com/steakknife/hamming v0.0.0-20161012051909-5ac3f73b8842 + github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 github.com/stretchr/testify v1.2.2 github.com/tensorflow/tensorflow v1.10.1 github.com/ugorji/go v1.1.1 diff --git a/go.sum b/go.sum index 1f0094537..1a30182b1 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/rwcarlsen/goexif v0.0.0-20180518182100-8d986c03457a h1:ZDZdsnbMuRSoVb github.com/rwcarlsen/goexif v0.0.0-20180518182100-8d986c03457a/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/steakknife/hamming v0.0.0-20161012051909-5ac3f73b8842 h1:Xk8V2cXXyb8xE/JOy2d8+0byqbKS1pEhVaeENndbaME= github.com/steakknife/hamming v0.0.0-20161012051909-5ac3f73b8842/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= +github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM= +github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tensorflow/tensorflow v1.10.0 h1:TVlKz+s8FPTwEBI98rhB2MR+8S46bK1Rp4bcIFCd7VQ= diff --git a/importer_test.go b/importer_test.go index 7082e7957..014fa5ed2 100644 --- a/importer_test.go +++ b/importer_test.go @@ -41,5 +41,5 @@ func TestImporter_GetDestinationFilename(t *testing.T) { assert.Empty(t, err) - assert.Equal(t, conf.OriginalsPath + "/2018/02/20180204_170813_B0770443A5F7.cr2", filename) + assert.Equal(t, conf.OriginalsPath+"/2018/02/20180204_170813_B0770443A5F7.cr2", filename) } diff --git a/indexer.go b/indexer.go index 7ccfccad5..654fe7e8e 100644 --- a/indexer.go +++ b/indexer.go @@ -2,12 +2,12 @@ package photoprism import ( "github.com/jinzhu/gorm" - "os" - "strings" - "path/filepath" - "log" - "io/ioutil" "github.com/photoprism/photoprism/recognize" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" ) type Indexer struct { diff --git a/location.go b/location.go index 9261a5442..0c9b6bb44 100644 --- a/location.go +++ b/location.go @@ -1,12 +1,12 @@ package photoprism import ( - "fmt" "encoding/json" - "net/http" - "github.com/jinzhu/gorm" - "strconv" "errors" + "fmt" + "github.com/jinzhu/gorm" + "net/http" + "strconv" ) type Location struct { @@ -36,7 +36,7 @@ type OpenstreetmapAddress struct { } type OpenstreetmapLocation struct { - PlaceId string `json:"place_id"` + PlaceId string `json:"place_id"` Lat string `json:"lat"` Lon string `json:"lon"` Category string `json:"category"` diff --git a/mediafile.go b/mediafile.go index bc6843c2d..7a1a97b88 100644 --- a/mediafile.go +++ b/mediafile.go @@ -4,20 +4,20 @@ import ( "encoding/hex" "github.com/brett-lempereur/ish" "github.com/djherbis/times" + "github.com/pkg/errors" "github.com/steakknife/hamming" + "image" + _ "image/gif" + _ "image/jpeg" + _ "image/png" "io" "log" + "math" "net/http" "os" "path/filepath" "strings" "time" - "github.com/pkg/errors" - "image" - _ "image/jpeg" - _ "image/png" - _ "image/gif" - "math" ) const ( diff --git a/mediafile_exif.go b/mediafile_exif.go index 073bfd7bc..bdad94100 100644 --- a/mediafile_exif.go +++ b/mediafile_exif.go @@ -86,6 +86,5 @@ func (m *MediaFile) GetExifData() (*ExifData, error) { m.exifData.Orientation = 1 } - return m.exifData, nil } diff --git a/query.go b/query.go index db7a5d3af..da136efb7 100644 --- a/query.go +++ b/query.go @@ -18,13 +18,13 @@ func NewQuery(originalsPath string, db *gorm.DB) *Search { return instance } -func (s *Search) FindPhotos (query string, count int, offset int) (photos []Photo) { +func (s *Search) FindPhotos(query string, count int, offset int) (photos []Photo) { q := s.db.Preload("Tags").Preload("Files").Preload("Location").Preload("Albums") if query != "" { q = q.Joins("JOIN photo_tags ON photo_tags.photo_id=photos.id") q = q.Joins("JOIN tags ON photo_tags.tag_id=tags.id") - q = q.Where("tags.label LIKE ?", "%" + query + "%") + q = q.Where("tags.label LIKE ?", "%"+query+"%") } q = q.Where(&Photo{Deleted: false}).Order("taken_at").Limit(count).Offset(offset) @@ -33,14 +33,14 @@ func (s *Search) FindPhotos (query string, count int, offset int) (photos []Phot return photos } -func (s *Search) FindFiles (count int, offset int) (files []File) { +func (s *Search) FindFiles(count int, offset int) (files []File) { s.db.Where(&File{}).Limit(count).Offset(offset).Find(&files) return files } -func (s *Search) FindFile (id string) (file File) { +func (s *Search) FindFile(id string) (file File) { s.db.Where("id = ?", id).First(&file) return file -} \ No newline at end of file +} diff --git a/recognize/recognize.go b/recognize/recognize.go index 8ff4d3378..de5dd2aea 100644 --- a/recognize/recognize.go +++ b/recognize/recognize.go @@ -2,12 +2,12 @@ package recognize import ( "bufio" + "errors" + tf "github.com/tensorflow/tensorflow/tensorflow/go" "io/ioutil" + "log" "os" "sort" - tf "github.com/tensorflow/tensorflow/tensorflow/go" - "log" - "errors" ) type ClassifyResult struct { diff --git a/recognize/recognize_test.go b/recognize/recognize_test.go index d594e05d6..4ec598b55 100644 --- a/recognize/recognize_test.go +++ b/recognize/recognize_test.go @@ -1,9 +1,9 @@ package recognize import ( - "testing" - "io/ioutil" "github.com/stretchr/testify/assert" + "io/ioutil" + "testing" ) func TestGetImageTags(t *testing.T) { @@ -22,4 +22,4 @@ func TestGetImageTags(t *testing.T) { assert.Equal(t, float32(0.23251747), result[1].Probability) } -} \ No newline at end of file +} diff --git a/server/server.go b/server/server.go index 1fc1adfbd..783cc9211 100644 --- a/server/server.go +++ b/server/server.go @@ -1,13 +1,13 @@ package server import ( - "github.com/gin-gonic/gin" "fmt" - "net/http" - "github.com/photoprism/photoprism" - "strconv" - "github.com/photoprism/photoprism/server/forms" + "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" + "github.com/photoprism/photoprism" + "github.com/photoprism/photoprism/server/forms" + "net/http" + "strconv" ) func Start(address string, port int, conf *photoprism.Config) { diff --git a/thumbnails.go b/thumbnails.go index cb9eb48d6..dccfba6b6 100644 --- a/thumbnails.go +++ b/thumbnails.go @@ -3,11 +3,11 @@ package photoprism import ( "fmt" "github.com/disintegration/imaging" + "image" "log" "os" "path/filepath" "strings" - "image" ) func CreateThumbnailsFromOriginals(originalsPath string, thumbnailsPath string, size int, square bool) {