setu

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Overview

Package setu 统一图床

Index

Constants

View Source
const DefaultPoolDir = "data/setupool"

DefaultPoolDir ...

Variables

View Source
var (
	// ErrNilFolder ...
	ErrNilFolder = errors.New("nil folder")
	// ErrNoSuchType ...
	ErrNoSuchType = errors.New("no such type")
	// ErrEmptyType ...
	ErrEmptyType = errors.New("empty type")
)
View Source
var DefaultPool = func() *Pool {
	p, err := NewPool(DefaultPoolDir, func(s string) (string, error) {
		typ := DefaultPoolDir + "/" + s
		if file.IsNotExist(typ) {
			err := os.MkdirAll(typ, 0755)
			if err != nil {
				return "", err
			}
		}
		return "https://img.moehu.org/pic.php?id=pc", nil
	}, web.GetData, time.Minute)
	if err != nil {
		panic(err)
	}
	return p
}()

DefaultPool ...

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool ...

func NewPool

func NewPool(folder string, rolimg func(string) (string, error), getdat func(string) ([]byte, error), timeout time.Duration) (*Pool, error)

NewPool 新的缓存池

func (*Pool) Roll

func (p *Pool) Roll(typ string) (string, error)

Roll 从缓存池随机挑一张

func (*Pool) RollLocal

func (p *Pool) RollLocal(typ string) (string, error)

RollLocal ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL