Permalink
Browse files

Implement some suggestions from gocritic and gometalinter.

  • Loading branch information...
aaron42net committed Jul 13, 2018
1 parent 270714e commit 7a14f440ee686fa3bb12c9749b386e6081860b10
View
@@ -20,7 +20,7 @@ func getRlimitMax(resource int) int {
return 0
}
func setRlimit(resource int, value int) {
func setRlimit(resource, value int) {
rlimit := &syscall.Rlimit{Cur: uint64(value), Max: uint64(value)}
err := syscall.Setrlimit(resource, rlimit)
View
@@ -8,7 +8,7 @@ import (
const (
// FotomatVersion is updated by git-hooks/pre-commit
FotomatVersion = "2.8.222"
FotomatVersion = "2.8.231"
)
var (
View
@@ -62,7 +62,7 @@ func (orientation Orientation) Dimensions(width, height int) (int, int) {
}
// Crop translates crop parameters from virtual coordinates to match the current physical Orientation.
func (orientation Orientation) Crop(ow, oh int, x, y int, iw, ih int) (int, int, int, int) {
func (orientation Orientation) Crop(ow, oh, x, y, iw, ih int) (int, int, int, int) {
oi := &orientationInfo[orientation]
if oi.swapXY {
@@ -71,10 +71,10 @@ func (orientation Orientation) Crop(ow, oh int, x, y int, iw, ih int) (int, int,
iw, ih = ih, iw
}
if oi.flipX {
x = int(iw) - int(ow) - x
x = iw - ow - x
}
if oi.flipY {
y = int(ih) - int(oh) - y
y = ih - oh - y
}
return x, y, ow, oh
}
View
@@ -32,15 +32,15 @@ type Options struct {
// Crop enables crop mode, where exact supplied Width:Height aspect
// ratio is preserved and excess pixels are trimmed from the sides.
Crop bool
// MaxBufferPixels specifies how large of an intermediate image
// buffer to allow, in pixels. RAM usage will be a few bytes per pixel.
MaxBufferPixels int
// Sharpen runs a mild sharpening pass on downsampled images.
Sharpen bool
// BlurSigma performs a gaussian blur with specified sigma.
BlurSigma float64
// FastResize reduces output image quality in some cases in favor of speed.
FastResize bool
// BlurSigma performs a gaussian blur with specified sigma.
BlurSigma float64
// MaxBufferPixels specifies how large of an intermediate image
// buffer to allow, in pixels. RAM usage will be a few bytes per pixel.
MaxBufferPixels int
// MaxQueueDuration limits the amount of time spent in a queue before processing starts.
MaxQueueDuration time.Duration
// MaxProcessingDuration limits the amount of time processing an
View
@@ -117,7 +117,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, or *http.Request) {
}
w.Header().Set("Content-Length", strconv.Itoa(len(thumb)))
w.Write(thumb)
_, _ = w.Write(thumb)
}
func (p *Proxy) get(url string, header http.Header) ([]byte, http.Header, int, error) {
@@ -137,7 +137,7 @@ func (p *Proxy) get(url string, header http.Header) ([]byte, http.Header, int, e
}
orig, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return orig, resp.Header, resp.StatusCode, err
}
@@ -149,15 +149,15 @@ func (p *Proxy) Close() {
*p = Proxy{}
}
func copyHeaders(src http.Header, dest http.Header, keys []string) {
func copyHeaders(src, dest http.Header, keys []string) {
for _, key := range keys {
if value, ok := src[key]; ok {
dest[key] = value
}
}
}
func isNotModified(req http.Header, resp http.Header) bool {
func isNotModified(req, resp http.Header) bool {
etag := resp.Get("Etag")
match := req.Get("If-None-Match")
// TODO: Support the multi-valued form of If-None-Match.
View
@@ -65,7 +65,7 @@ type proxyServer struct {
host string
}
func newProxyServer(delay time.Duration, timeout time.Duration) *proxyServer {
func newProxyServer(delay, timeout time.Duration) *proxyServer {
// Static http server that serves our test images, with a delay.
fs := http.FileServer(http.Dir(imageDirectory))
origin := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
View
@@ -54,18 +54,18 @@ func Thumbnail(blob []byte, o Options) ([]byte, error) {
}
defer image.Close()
if err := srgb(image); err != nil {
if err = srgb(image); err != nil {
return nil, err
}
if err := resize(image, iw, ih, o.FastResize, o.BlurSigma, o.Sharpen && shrinking); err != nil {
if err = resize(image, iw, ih, o.FastResize, o.BlurSigma, o.Sharpen && shrinking); err != nil {
return nil, err
}
// Make sure we generate images with 8 bits per channel. Do this before the
// rotate to reduce the amount of data that needs to be copied.
if image.ImageGetBandFormat() != vips.BandFormatUchar {
if err := image.Cast(vips.BandFormatUchar); err != nil {
if err = image.Cast(vips.BandFormatUchar); err != nil {
return nil, err
}
}
View
@@ -82,7 +82,7 @@ func minTransparency(image *vips.Image) (float64, error) {
}
defer band.Close()
if err := band.ExtractBand(band.ImageGetBands()-1, 1); err != nil {
if err = band.ExtractBand(band.ImageGetBands()-1, 1); err != nil {
return 0, err
}
View
@@ -66,7 +66,7 @@ func (in *Image) IccImport() error {
// IccTransform transform an image with a pair of ICC profiles. The input
// image is moved to profile-connection space with the input profile and
// then to the output space with the output profile and intent.
func (in *Image) IccTransform(outputProfileFilename string, inputProfileFilename string, intent Intent) error {
func (in *Image) IccTransform(outputProfileFilename, inputProfileFilename string, intent Intent) error {
var out *C.struct__VipsImage
co := C.CString(outputProfileFilename)
var ci *C.char
View
@@ -29,7 +29,7 @@ func NewInterpolate(name string) *Interpolate {
}
// Close frees resources from an Interpolate.
func (i Interpolate) Close() {
func (i *Interpolate) Close() {
C.g_object_unref(C.gpointer(i.interpolate))
i.interpolate = nil
}

0 comments on commit 7a14f44

Please sign in to comment.