global

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IsYes = 1
	IsNo  = 0

	DateTimeFormatStr = time.DateTime
	DateFormatStr     = time.DateOnly

	TwitterProtocol = "/ethtweet/0.1"
	Version         = "0.8.0"
)

这个包放置公共常量

View Source
const (
	DBDriveSqlite = "sqlite"
	DBDriveMysql  = "mysql"
)
View Source
const DefaultPageSize = 20
View Source
const SqliteDatabaseDefaultDir = "databases"
View Source
const SqliteDatabaseName = "EthTweet.0.2.db"

Variables

View Source
var DbDrive = ""
View Source
var ErrCtxCancel = errors.New("ctx cancel")
View Source
var ErrTimeout = errors.New("timeout")
View Source
var ErrTweetNonceConflict = fmt.Errorf("tweet nonce conflict")
View Source
var ErrUserAskTimeout = fmt.Errorf("do ask timeout.....")
View Source
var ErrUserAskWriteAllFail = fmt.Errorf("do ask write all fail.....")
View Source
var ErrWaitUserSync = fmt.Errorf("Synchronizing user data, please wait...")
View Source
var (
	IpfsApi string
)

Functions

func Base58ToPubKey

func Base58ToPubKey(str string) (*ecdsa.PublicKey, error)

func CancelGlobalCtx

func CancelGlobalCtx()

func CheckWindowsMysqld

func CheckWindowsMysqld() error

func EthPriToLibP2pPri

func EthPriToLibP2pPri(pri *ecdsa.PrivateKey) (crypto.PrivKey, error)

func EthSignHash

func EthSignHash(msg string) []byte

func ExecCmd

func ExecCmd(name string, args ...string) error

func FileExists

func FileExists(path string) bool

func FormatEthSignMsg

func FormatEthSignMsg(msg string) string

func GenerateRangeNum

func GenerateRangeNum(min, max int64) int64

func GetDB

func GetDB() *gorm.DB

func GetGlobalCtx

func GetGlobalCtx() context.Context

func GetIpfsInfo

func GetIpfsInfo(h string) ([]byte, error)

func Hour2Unix

func Hour2Unix(hour string) (time.Time, error)

func InitSqliteDatabase

func InitSqliteDatabase(dir, name string) error

func IsDir

func IsDir(path string) bool

func IsLocalIp

func IsLocalIp(ip string) bool

func Json2Map

func Json2Map(j string) map[string]interface{}

func LibP2pPriToAddress

func LibP2pPriToAddress(pri crypto.PrivKey) (common.Address, error)

func LibP2pPriToEthPri

func LibP2pPriToEthPri(pri crypto.PrivKey) (*ecdsa.PrivateKey, error)

func Md5

func Md5(s string) string

func PingMysql

func PingMysql() error

func PwdPlaintext2CipherText

func PwdPlaintext2CipherText(pwd string, salt string) string

func RandFloats

func RandFloats(min, max float64, n int) float64

func RandStringRunes

func RandStringRunes(n int) string

func ReloadIpfsGateway

func ReloadIpfsGateway() error

func RemoveDuplicationByMap

func RemoveDuplicationByMap(arr []string, before func(string2 *string)) []string

func RunWindowsMysqld

func RunWindowsMysqld() error

func SetMysqlDB

func SetMysqlDB(db *MysqlDb)

func StrLen

func StrLen(str string) int

func UploadIpfs

func UploadIpfs(data interface{}) (string, error)

func UploadIpfsReader

func UploadIpfsReader(r *bytes.Reader) (string, error)

Types

type Context

type Context struct {
	Ctx context.Context
	Cc  context.CancelFunc
}

func NewContext

func NewContext(parent context.Context) *Context

type MysqlDb

type MysqlDb struct {
	Host          string
	Port          string
	Database      string
	Charset       string
	UserName      string
	Password      string
	MaxIdleCounts int
	*gorm.DB
}

func GetMysqlDB

func GetMysqlDB() *MysqlDb

func NewDatabaseMysql

func NewDatabaseMysql(host, port, database, charset, username, password string, maxIdleCounts int, maxOpenCounts int) (*MysqlDb, error)

type Pager

type Pager struct {
	Offset  int
	Limit   int
	Current int
}

func NewPager

func NewPager(ctx iris.Context) *Pager

type SqliteDB

type SqliteDB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func GetSqliteDB

func GetSqliteDB() *SqliteDB

func (*SqliteDB) GetDsn

func (sdb *SqliteDB) GetDsn() string

Jump to

Keyboard shortcuts

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