Golang Assets File Of GoCaptcha

May 18, 2025 ยท View on GitHub

Go Captcha presets some default embedded resources and stores them in the Go file format. In addition, you can also configure the captcha according to your own needs.

Source Resources File: https://github.com/wenlng/go-captcha-resources

Install

$ go get -u github.com/wenlng/go-captcha-assets@latest

Use Assets

Chinese Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetChineseChars()
}

Alpha Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetAlphaChars()
}

Alpha Mixin Text Assets

import "github.com/wenlng/go-captcha-assets/bindata/chars"

func Demo() {
    chars := chars.GetMixinAlphaChars()
}

Font Assets

import "github.com/wenlng/go-captcha-assets/resources/fonts/fzshengsksjw"

func Demo() {
    fonts, err := fzshengsksjw.GetFont()
    if err != nil {
        log.Fatalln(err)
    }
}

Image Assets

//import "github.com/wenlng/go-captcha-assets/resources/images"
import "github.com/wenlng/go-captcha-assets/resources/imagesv2"

func Demo() {
    imgs, err := imagesv2.GetImages()
    if err != nil {
        log.Fatalln(err)
    }
}

Shape Assets

import "github.com/wenlng/go-captcha-assets/resources/shapes"

func Demo() {
    shapeMaps, err := shapes.GetShapes()
    if err != nil {
        log.Fatalln(err)
    }
}

Thumbnail Assets

import "github.com/wenlng/go-captcha-assets/resources/thumb"

func Demo() {
    imgs, err := thumb.GetImages()
    if err != nil {
        log.Fatalln(err)
    }
}

Tile Assets

import "github.com/wenlng/go-captcha-assets/resources/tiles"

func Demo() {
    graphs, err := tiles.GetTiles()
    if err != nil {
        log.Fatalln(err)
    }
    
    // slide
    var newGraphs = make([]*slide.GraphImage, 0, len(graphs))
    for i := 0; i < len(graphs); i++ {
        graph := graphs[i]
        newGraphs = append(newGraphs, &slide.GraphImage{
            OverlayImage: graph.OverlayImage,
            MaskImage:    graph.MaskImage,
            ShadowImage:  graph.ShadowImage,
        })
    }
}

Load Asset As Needed

// Example
import assets "github.com/wenlng/go-captcha-assets/bindata/images/image_v2_1"

func Demo() error {
    asset, err = assets.Asset("sourcedata/images/image-v2-1/image.jpg")
    if err != nil {
    return err
    }
    img, err = helper.DecodeByteToJpeg(asset)
    if err != nil {
    return err
    }
    fmt.Println(img)
}
TypePackage PathAsset PathImage
Imagebindata/images/image_v2_1sourcedata/images/image-v2-1/image.jpg
Imagebindata/images/image_v2_2sourcedata/images/image-v2-2/image.jpg
Imagebindata/images/image_v2_3sourcedata/images/image-v2-3/image.jpg
Imagebindata/images/image_v2_4sourcedata/images/image-v2-4/image.jpg
Imagebindata/images/image_v2_5sourcedata/images/image-v2-5/image.jpg
Imagebindata/images/image_v2_6sourcedata/images/image-v2-6/image.jpg
Imagebindata/images/image_v2_7sourcedata/images/image-v2-7/image.jpg
Imagebindata/images/image_v2_8sourcedata/images/image-v2-8/image.jpg
Imagebindata/images/image_v2_9sourcedata/images/image-v2-9/image.jpg
Imagebindata/images/image_v2_10sourcedata/images/image-v2-10/image.jpg
Imagebindata/images/image_v2_11sourcedata/images/image-v2-11/image.jpg
Imagebindata/images/image_v2_12sourcedata/images/image-v2-12/image.jpg
Imagebindata/images/image_v2_13sourcedata/images/image-v2-13/image.jpg
Imagebindata/images/image_v2_14sourcedata/images/image-v2-14/image.jpg
Imagebindata/images/image_v2_15sourcedata/images/image-v2-15/image.jpg
Imagebindata/images/image_v2_16sourcedata/images/image-v2-16/image.jpg
-
Thumbbindata/thumbs/thumb_1sourcedata/thumbs/thumb-1/thumb.jpg
Thumbbindata/thumbs/thumb_2sourcedata/thumbs/thumb-2/thumb.jpg
Thumbbindata/thumbs/thumb_3sourcedata/thumbs/thumb-3/thumb.jpg
Thumbbindata/thumbs/thumb_4sourcedata/thumbs/thumb-4/thumb.jpg
Thumbbindata/thumbs/thumb_5sourcedata/thumbs/thumb-5/thumb.jpg
-
Tilebindata/tiles/tile_1sourcedata/tiles/tile-1/tile.png
Tilebindata/tiles/tile_1sourcedata/tiles/tile-1/tile-shadow.png
Tilebindata/tiles/tile_1sourcedata/tiles/tile-1/tile-mask.png
Tilebindata/tiles/tile_2sourcedata/tiles/tile-2/tile.png
Tilebindata/tiles/tile_2sourcedata/tiles/tile-2/tile-shadow.png
Tilebindata/tiles/tile_2sourcedata/tiles/tile-2/tile-mask.png
Tilebindata/tiles/tile_3sourcedata/tiles/tile-3/tile.png
Tilebindata/tiles/tile_3sourcedata/tiles/tile-3/tile-shadow.png
Tilebindata/tiles/tile_3sourcedata/tiles/tile-3/tile-mask.png
Tilebindata/tiles/tile_4sourcedata/tiles/tile-4/tile.png
Tilebindata/tiles/tile_4sourcedata/tiles/tile-4/tile-shadow.png
Tilebindata/tiles/tile_4sourcedata/tiles/tile-4/tile-mask.png
-
Shapebindata/shapes/shape_1sourcedata/shapes/shape-1/shape.png
Shapebindata/shapes/shape_2sourcedata/shapes/shape-2/shape.png
Shapebindata/shapes/shape_3sourcedata/shapes/shape-3/shape.png
Shapebindata/shapes/shape_4sourcedata/shapes/shape-4/shape.png
Shapebindata/shapes/shape_5sourcedata/shapes/shape-5/shape.png
Shapebindata/shapes/shape_6sourcedata/shapes/shape-6/shape.png
Shapebindata/shapes/shape_7sourcedata/shapes/shape-7/shape.png
Shapebindata/shapes/shape_8sourcedata/shapes/shape-8/shape.png
Shapebindata/shapes/shape_9sourcedata/shapes/shape-9/shape.png
Shapebindata/shapes/shape_10sourcedata/shapes/shape-10/shape.png
Shapebindata/shapes/shape_11sourcedata/shapes/shape-11/shape.png
Shapebindata/shapes/shape_12sourcedata/shapes/shape-12/shape.png
Shapebindata/shapes/shape_13sourcedata/shapes/shape-13/shape.png
-
Fontbindata/fonts/fzshengsksjw_cusourcedata/fonts/fzshengsksjw_cu/font.ttf