init
This commit is contained in:
50
quick_test.go
Normal file
50
quick_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/kevin/go-jdenticon/jdenticon"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Quick test - generate an avatar for your GitHub username or email
|
||||
|
||||
// Change this to your email or username!
|
||||
userInput := "your-email@example.com"
|
||||
|
||||
fmt.Printf("🎨 Generating avatar for: %s\n", userInput)
|
||||
|
||||
// Generate SVG (good for web use)
|
||||
svg, err := jdenticon.ToSVG(userInput, 100)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = os.WriteFile("my_avatar.svg", []byte(svg), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Generate PNG (good for Discord, Slack, etc.)
|
||||
png, err := jdenticon.ToPNG(userInput, 100)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = os.WriteFile("my_avatar.png", png, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("✅ Generated my_avatar.svg and my_avatar.png")
|
||||
fmt.Printf("📊 SVG: %d chars, PNG: %d bytes\n", len(svg), len(png))
|
||||
|
||||
// Show that the same input always produces the same avatar
|
||||
svg2, _ := jdenticon.ToSVG(userInput, 100)
|
||||
fmt.Printf("🔒 Deterministic: %v\n", svg == svg2)
|
||||
|
||||
// Show the hash that determines the avatar
|
||||
hash := jdenticon.ToHash(userInput)
|
||||
fmt.Printf("🔢 Hash: %s\n", hash)
|
||||
}
|
||||
Reference in New Issue
Block a user