Formatted code (go fmt ./...)

This commit is contained in:
Michael Mayer 2018-09-06 14:47:32 +02:00
parent 3da127435c
commit 1716c5a38f
14 changed files with 43 additions and 39 deletions

View file

@ -6,6 +6,7 @@ GORUN=$(GOCMD) run
GOCLEAN=$(GOCMD) clean GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get GOGET=$(GOCMD) get
GOFMT=$(GOCMD) fmt
BINARY_NAME=photoprism BINARY_NAME=photoprism
all: deps js build all: deps js build
@ -28,6 +29,8 @@ clean:
image: image:
docker build . --tag photoprism/photoprism docker build . --tag photoprism/photoprism
docker push photoprism/photoprism docker push photoprism/photoprism
format:
$(GOFMT) ./...
deps: deps:
$(GOBUILD) -v ./... $(GOBUILD) -v ./...
upgrade: upgrade:

View file

@ -2,11 +2,11 @@ package main
import ( import (
"fmt" "fmt"
"github.com/araddon/dateparse"
"github.com/photoprism/photoprism" "github.com/photoprism/photoprism"
"github.com/photoprism/photoprism/server"
"github.com/urfave/cli" "github.com/urfave/cli"
"os" "os"
"github.com/araddon/dateparse"
"github.com/photoprism/photoprism/server"
) )
func main() { 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") size := context.Int("size")
originals := photoprism.FindOriginalsByDate(conf.OriginalsPath, afterDate, beforeDate) originals := photoprism.FindOriginalsByDate(conf.OriginalsPath, afterDate, beforeDate)

2
go.mod
View file

@ -25,7 +25,7 @@ require (
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib v1.0.0
github.com/rwcarlsen/goexif v0.0.0-20180518182100-8d986c03457a 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/stretchr/testify v1.2.2
github.com/tensorflow/tensorflow v1.10.1 github.com/tensorflow/tensorflow v1.10.1
github.com/ugorji/go v1.1.1 github.com/ugorji/go v1.1.1

2
go.sum
View file

@ -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/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 h1:Xk8V2cXXyb8xE/JOy2d8+0byqbKS1pEhVaeENndbaME=
github.com/steakknife/hamming v0.0.0-20161012051909-5ac3f73b8842/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= 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 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/tensorflow/tensorflow v1.10.0 h1:TVlKz+s8FPTwEBI98rhB2MR+8S46bK1Rp4bcIFCd7VQ= github.com/tensorflow/tensorflow v1.10.0 h1:TVlKz+s8FPTwEBI98rhB2MR+8S46bK1Rp4bcIFCd7VQ=

View file

@ -41,5 +41,5 @@ func TestImporter_GetDestinationFilename(t *testing.T) {
assert.Empty(t, err) 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)
} }

View file

@ -2,12 +2,12 @@ package photoprism
import ( import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"os"
"strings"
"path/filepath"
"log"
"io/ioutil"
"github.com/photoprism/photoprism/recognize" "github.com/photoprism/photoprism/recognize"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
) )
type Indexer struct { type Indexer struct {

View file

@ -1,12 +1,12 @@
package photoprism package photoprism
import ( import (
"fmt"
"encoding/json" "encoding/json"
"net/http"
"github.com/jinzhu/gorm"
"strconv"
"errors" "errors"
"fmt"
"github.com/jinzhu/gorm"
"net/http"
"strconv"
) )
type Location struct { type Location struct {
@ -36,7 +36,7 @@ type OpenstreetmapAddress struct {
} }
type OpenstreetmapLocation struct { type OpenstreetmapLocation struct {
PlaceId string `json:"place_id"` PlaceId string `json:"place_id"`
Lat string `json:"lat"` Lat string `json:"lat"`
Lon string `json:"lon"` Lon string `json:"lon"`
Category string `json:"category"` Category string `json:"category"`

View file

@ -4,20 +4,20 @@ import (
"encoding/hex" "encoding/hex"
"github.com/brett-lempereur/ish" "github.com/brett-lempereur/ish"
"github.com/djherbis/times" "github.com/djherbis/times"
"github.com/pkg/errors"
"github.com/steakknife/hamming" "github.com/steakknife/hamming"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"io" "io"
"log" "log"
"math"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
"github.com/pkg/errors"
"image"
_ "image/jpeg"
_ "image/png"
_ "image/gif"
"math"
) )
const ( const (

View file

@ -86,6 +86,5 @@ func (m *MediaFile) GetExifData() (*ExifData, error) {
m.exifData.Orientation = 1 m.exifData.Orientation = 1
} }
return m.exifData, nil return m.exifData, nil
} }

View file

@ -18,13 +18,13 @@ func NewQuery(originalsPath string, db *gorm.DB) *Search {
return instance 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") q := s.db.Preload("Tags").Preload("Files").Preload("Location").Preload("Albums")
if query != "" { if query != "" {
q = q.Joins("JOIN photo_tags ON photo_tags.photo_id=photos.id") 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.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) 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 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) s.db.Where(&File{}).Limit(count).Offset(offset).Find(&files)
return 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) s.db.Where("id = ?", id).First(&file)
return file return file
} }

View file

@ -2,12 +2,12 @@ package recognize
import ( import (
"bufio" "bufio"
"errors"
tf "github.com/tensorflow/tensorflow/tensorflow/go"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"sort" "sort"
tf "github.com/tensorflow/tensorflow/tensorflow/go"
"log"
"errors"
) )
type ClassifyResult struct { type ClassifyResult struct {

View file

@ -1,9 +1,9 @@
package recognize package recognize
import ( import (
"testing"
"io/ioutil"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
) )
func TestGetImageTags(t *testing.T) { func TestGetImageTags(t *testing.T) {
@ -22,4 +22,4 @@ func TestGetImageTags(t *testing.T) {
assert.Equal(t, float32(0.23251747), result[1].Probability) assert.Equal(t, float32(0.23251747), result[1].Probability)
} }
} }

View file

@ -1,13 +1,13 @@
package server package server
import ( import (
"github.com/gin-gonic/gin"
"fmt" "fmt"
"net/http" "github.com/gin-gonic/gin"
"github.com/photoprism/photoprism"
"strconv"
"github.com/photoprism/photoprism/server/forms"
"github.com/gin-gonic/gin/binding" "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) { func Start(address string, port int, conf *photoprism.Config) {

View file

@ -3,11 +3,11 @@ package photoprism
import ( import (
"fmt" "fmt"
"github.com/disintegration/imaging" "github.com/disintegration/imaging"
"image"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"image"
) )
func CreateThumbnailsFromOriginals(originalsPath string, thumbnailsPath string, size int, square bool) { func CreateThumbnailsFromOriginals(originalsPath string, thumbnailsPath string, size int, square bool) {