Skip to content

Commit

Permalink
cleanup: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
theredrad committed Sep 25, 2021
1 parent f71a858 commit 181d2f2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
26 changes: 13 additions & 13 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
type Options struct {
CacheFiles bool

MinWidth int
MaxWidth int
MinWidth int
MaxWidth int
MinHeight int
MaxHeight int
}
Expand All @@ -32,18 +32,18 @@ const (

type API struct {
mngr *manager.Manager
pr image.Processor
opt *Options
pr image.Processor
opt *Options
}

func New(manager *manager.Manager, imageProcessor image.Processor, options *Options) *API {
if options == nil {
options = &Options{
CacheFiles: true,
MinWidth: minSize,
MinHeight: minSize,
MaxWidth: maxSize,
MaxHeight: maxSize,
MinWidth: minSize,
MinHeight: minSize,
MaxWidth: maxSize,
MaxHeight: maxSize,
}
} else {
if options.MinWidth == 0 {
Expand All @@ -65,8 +65,8 @@ func New(manager *manager.Manager, imageProcessor image.Processor, options *Opti

return &API{
mngr: manager,
pr: imageProcessor,
opt: options,
pr: imageProcessor,
opt: options,
}
}

Expand Down Expand Up @@ -198,11 +198,11 @@ func cacheFile(cp string, i []byte) error {

func cachePath(file string, width, height int) string {
tmp := strings.Split(file, "/")
tmp[len(tmp) - 1] = fmt.Sprintf("%s/%dx%d/%s", ".cache", width, height, tmp[len(tmp) - 1])
tmp[len(tmp)-1] = fmt.Sprintf("%s/%dx%d/%s", ".cache", width, height, tmp[len(tmp)-1])
return strings.Join(tmp, "/")
}

func path(file string) string {
tmp := strings.Split(file, "/")
return strings.Join(tmp[:len(tmp) - 1], "/")
}
return strings.Join(tmp[:len(tmp)-1], "/")
}
2 changes: 1 addition & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package api

type Error struct {
Message string `json:"message"`
}
}
2 changes: 1 addition & 1 deletion image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ func Decode(name string) (*image.Image, error) {
}

return &img, nil
}
}
2 changes: 1 addition & 1 deletion image/imaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"image"
)

type Imaging struct {}
type Imaging struct{}

func (i *Imaging) CropCenter(img image.Image, width, height int) *image.Image {
img = imaging.Fill(img, width, height, imaging.Center, imaging.Lanczos)
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ func main() {
log.Panic("HTTP server failed to start")
}
}

11 changes: 5 additions & 6 deletions manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const (

type Manager struct {
base string
ds map[string][]string
mc []string // index of categories
ds map[string][]string
mc []string // index of categories
}

func New(dir string) (*Manager, error) {
Expand All @@ -29,12 +29,11 @@ func New(dir string) (*Manager, error) {

return &Manager{
base: dir,
ds: ds,
mc: mc,
ds: ds,
mc: mc,
}, nil
}


func (m *Manager) Pick(cat string) string {
if cat == "" {
cat = m.randomCategory()
Expand Down Expand Up @@ -68,4 +67,4 @@ func (m *Manager) randomEntity(c string) string {
names = append(names, m.ds[c][rand.Intn(len(m.ds[c]))])

return strings.Join(names, "/")
}
}

0 comments on commit 181d2f2

Please sign in to comment.