Skip to content

Commit ab92a03

Browse files
committed
Update dependencies and cleanup code
1 parent 068cd69 commit ab92a03

File tree

6 files changed

+24
-32
lines changed

6 files changed

+24
-32
lines changed

avatars.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ func (a *Avatar) Image(opts ...RenderOption) (image.Image, error) {
6767
opt := renderOptions(opts...)
6868

6969
gc := gg.NewContext(opt.Size, opt.Size)
70-
rendr_gg.Draw(gc, s, renderer.Target(
70+
if err := rendr_gg.Draw(gc, s, renderer.Target(
7171
float64(opt.Padding),
7272
float64(opt.Padding),
7373
float64(opt.Size-opt.Padding*2),
7474
float64(opt.Size-opt.Padding*2),
75-
))
75+
)); err != nil {
76+
return nil, err
77+
}
7678

7779
return gc.Image(), nil
7880
}

example/sample/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ func main() {
3232
panic(err)
3333
}
3434
defer f.Close()
35-
png.Encode(f, img)
35+
36+
if err := png.Encode(f, img); err != nil {
37+
panic(err)
38+
}
3639
}

example/test/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ func main() {
2525
if err != nil {
2626
panic(err)
2727
}
28-
if err := ioutil.WriteFile("test.svg", a.SVG(), fs.FileMode(0644)); err != nil {
28+
if err := ioutil.WriteFile("test.svg", a.SVG(), fs.FileMode(0o644)); err != nil {
2929
panic(err)
3030
}
3131
img, err := a.PNG(avatars.RenderSize(size))
3232
if err != nil {
3333
panic(err)
3434
}
35-
if err := ioutil.WriteFile("test.png", img, fs.FileMode(0644)); err != nil {
35+
if err := ioutil.WriteFile("test.png", img, fs.FileMode(0o644)); err != nil {
3636
panic(err)
3737
}
3838
}

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/lafriks/go-avatars
22

3-
go 1.17
3+
go 1.20
44

55
require (
66
github.com/fogleman/gg v1.3.0
7-
github.com/lafriks/go-svg v0.3.2
7+
github.com/lafriks/go-svg v0.4.0
88
)
99

1010
require (
1111
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
12-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
13-
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
14-
golang.org/x/text v0.3.7 // indirect
12+
golang.org/x/image v0.15.0 // indirect
13+
golang.org/x/net v0.21.0 // indirect
14+
golang.org/x/text v0.14.0 // indirect
1515
)

go.sum

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
22
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
3-
github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
4-
github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
53
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
64
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
7-
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
8-
github.com/lafriks/go-svg v0.3.2 h1:wuSgV5Jh+aSGe+zPwXIOo2qb3UBRMKtAQmGfWwgIPqM=
9-
github.com/lafriks/go-svg v0.3.2/go.mod h1:Gh57dXusEHiJBarKTI+t+LJVLU3Y7EvU/OUHWQUIBV0=
10-
github.com/llgcode/draw2d v0.0.0-20210904075650-80aa0a2a901d/go.mod h1:mVa0dA29Db2S4LVqDYLlsePDzRJLDfdhVZiI15uY0FA=
11-
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb/go.mod h1:1l8ky+Ew27CMX29uG+a2hNOKpeNYEQjjtiALiBlFQbY=
12-
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU=
13-
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
14-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
15-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
16-
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
17-
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
19-
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
20-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
21-
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
22-
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
23-
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
24-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5+
github.com/lafriks/go-svg v0.4.0 h1:XgciXbad7H0js3c0Uk47dmGFJ9pCRlG7vP+mlqDEq6w=
6+
github.com/lafriks/go-svg v0.4.0/go.mod h1:7Qj5mwY/s5NcPAZwbjyB/V8Hlet3ZYznx3ltPac2K+s=
7+
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
8+
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
9+
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
10+
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
11+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
12+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package avatars
22

33
// Options for the avatar service.
4-
type Options struct {
5-
}
4+
type Options struct{}
65

76
// Option is a function that applies an option to the avatar service.
87
type Option interface {

0 commit comments

Comments
 (0)