util

package
v0.0.0-...-329d92c Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceiOS     = "ios"
	DeviceAndroid = "android"

	ImagePath     = "./images/"
	QuestionImage = ImagePath + "question.png"
	AnswerImage   = ImagePath + "answer.png"

	BaiduAccessTokenKey = "qanswer_baidu_access_token"

	QuestionInCache = "something else"
)

Variables

This section is empty.

Functions

func CutImage

func CutImage(src image.Image, x, y, w, h int) (image.Image, error)

CutImage 裁剪图片

func GetCache

func GetCache() *cache.Cache

GetCache 获取cache对象

func HTTPGet

func HTTPGet(uri string, timeout int32) ([]byte, error)

HTTPGet 代理请求

func HTTPGetCustom

func HTTPGetCustom(uri string, timeout int32, proxyURL string, header http.Header) ([]byte, error)

HTTPGetCustom custom http client

func MkDirIfNotExist

func MkDirIfNotExist(path string) error

MkDirIfNotExist 如果指定文件夹不存在则创建

func MustInt32

func MustInt32(str string) int32

MustInt32 MustInt32

func OpenImageToBase64

func OpenImageToBase64(filename string) (string, error)

OpenImageToBase64 OpenImageToBase64

func OpenPNG

func OpenPNG(filename string) (image.Image, error)

OpenPNG 打开png图片

func PostForm

func PostForm(uri string, data url.Values, timeout int32) ([]byte, error)

PostForm PostForm

func SavePNG

func SavePNG(filename string, pic image.Image) error

SavePNG 保存png图片

func SetConfigFile

func SetConfigFile(path string)

SetConfigFile 设置配置文件地址

func SubString

func SubString(str string, begin, length int) (substr string)

SubString 截取中文字符串

func UnicodeIndex

func UnicodeIndex(str, substr string) int

UnicodeIndex 获取中文字符位置

Types

type Config

type Config struct {
	Debug          bool   `yaml:"debug"`
	APP            string `yaml:"app"`
	Auto           bool   `yaml:"automatic"`
	Device         string `yaml:"device"`
	OCR            string `yaml:"ocr"`
	AdbAddress     string `yaml:"adb_address"`
	WdaAddress     string `yaml:"wda_address"`
	BaiduAPIKey    string `yaml:"Baidu_API_Key"`
	BaiduSecretKey string `yaml:"Baidu_Secret_Key"`

	//西瓜视频截图题目位置
	XgQx int `yaml:"xg_q_x"`
	XgQy int `yaml:"xg_q_y"`
	XgQw int `yaml:"xg_q_w"`
	XgQh int `yaml:"xg_q_h"`
	//西瓜视频截取答案位置
	XgAx int `yaml:"xg_a_x"`
	XgAy int `yaml:"xg_a_y"`
	XgAw int `yaml:"xg_a_w"`
	XgAh int `yaml:"xg_a_h"`

	//冲顶大会截图题目位置
	CdQx int `yaml:"cd_q_x"`
	CdQy int `yaml:"cd_q_y"`
	CdQw int `yaml:"cd_q_w"`
	CdQh int `yaml:"cd_q_h"`
	//冲顶大会截取答案位置
	CdAx int `yaml:"cd_a_x"`
	CdAy int `yaml:"cd_a_y"`
	CdAw int `yaml:"cd_a_w"`
	CdAh int `yaml:"cd_a_h"`

	//花椒直播截图题目位置
	HjQx int `yaml:"hj_q_x"`
	HjQy int `yaml:"hj_q_y"`
	HjQw int `yaml:"hj_q_w"`
	HjQh int `yaml:"hj_q_h"`
	//花椒直播截取答案位置
	HjAx int `yaml:"hj_a_x"`
	HjAy int `yaml:"hj_a_y"`
	HjAw int `yaml:"hj_a_w"`
	HjAh int `yaml:"hj_a_h"`

	//芝士超人截图题目位置
	ZsQx int `yaml:"zs_q_x"`
	ZsQy int `yaml:"zs_q_y"`
	ZsQw int `yaml:"zs_q_w"`
	ZsQh int `yaml:"zs_q_h"`
	//芝士超人截取答案位置
	ZsAx int `yaml:"zs_a_x"`
	ZsAy int `yaml:"zs_a_y"`
	ZsAw int `yaml:"zs_a_w"`
	ZsAh int `yaml:"zs_a_h"`
}

Config 全局配置

func GetConfig

func GetConfig() *Config

GetConfig 解析配置

Jump to

Keyboard shortcuts

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