diff --git a/foundation/avatar.go b/foundation/avatar.go index 63dd5f6..f5b631c 100644 --- a/foundation/avatar.go +++ b/foundation/avatar.go @@ -8,14 +8,15 @@ var colors = []uint32{ 0xff6200, 0x42c58e, 0x5a8de1, 0x785fe0, } //生成头像的方式 -func GeneraterAvater(width int,height int,content string) []byte { +func GenerateAvatar(width int,height int,content string)( []byte,error) { ab := calc.NewAvatarBuilder("../static/SourceHanSansSC-Medium.ttf", &calc.SourceHansSansSCMedium{}) ab.SetBackgroundColorHex(colors[3]) ab.SetFrontgroundColor(color.White) ab.SetFontSize(80) ab.SetAvatarSize(width, height) - if data,err:=ab.GenerateImage(content);err==nil { - return data + data,err:=ab.GenerateImage(content) + if err!=nil { + return data,err } - return nil + return nil,err } diff --git a/foundation/avatar_test.go b/foundation/avatar_test.go index 2b2bc70..9a9dcf9 100644 --- a/foundation/avatar_test.go +++ b/foundation/avatar_test.go @@ -6,6 +6,6 @@ import ( func Test_ge(t *testing.T) { - GeneraterAvater() + GenerateAvatar() }