Skip to content

Commit

Permalink
repo: add examples test
Browse files Browse the repository at this point in the history
  • Loading branch information
laojianzi committed Nov 23, 2020
1 parent 6cacc4d commit d7554dc
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion examples/test/test.go
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
package test
package main

import (
"fmt"
"image/png"
"log"
"os"
"time"

"github.com/laojianzi/mdavatar"
)

func main() {
initials := "LR"
avatar, err := mdavatar.New(initials).Build()
if err != nil {
log.Fatal(err)
}

filename := fmt.Sprintf("out-%d.png", time.Now().Unix())
file, err := os.Create(filename)
if err != nil {
log.Fatal(err)
}
if err := png.Encode(file, avatar); err != nil {
panic(err)
}
}

0 comments on commit d7554dc

Please sign in to comment.