Documentation ¶
Index ¶
- Constants
- Variables
- func Aes128COMDecrypt(crypted string, constKey string) (string, error)
- func Aes128COMEncrypt(content string, constKey string) (string, error)
- func AesCBCDecrypt(crypted, key []byte) ([]byte, error)
- func AesCBCEncrypt(origData, key []byte) ([]byte, error)
- func AesCFBDecrypt(ciphertext string, privateKey string, publicKey string) (string, error)
- func AesCFBEncrypt(content string, privateKey string, publicKey string) (string, error)
- func AtPages(content string) ([]string, string)
- func AtPagesGetImages(content string) ([]string, string)
- func AtUsers(content string) (usrs []string)
- func AtWhois(content string) []string
- func Base64Encoding(s string) string
- func C2C(fromstr string, tostr string, str string) string
- func CheckEmail(email string) (b bool)
- func CheckPassword(password string) (b bool)
- func CheckUsername(username string) (b bool)
- func Compare(f, s, t string) bool
- func CompareDiff(fg1, fg2 string) int
- func Confidence(ups int64, downs int64) float64
- func Controversy(ups int64, downs int64) float64
- func ConvertToBase64(in string) string
- func ConvertToBase64ByPongo2(in *pongo2.Value) *pongo2.Value
- func Convzh(str string, lang string) []byte
- func CopyDir(source string, dest string) (err error)
- func CopyFile(source string, dest string) (err error)
- func CreateFile(dir string, name string) (string, error)
- func Cropword(in string, start int, length int, symbol string) string
- func CropwordByPongo2(in *pongo2.Value, start *pongo2.Value, length *pongo2.Value, ...) *pongo2.Value
- func DelFile(files []os.FileInfo, count int, fileDir string)
- func DelLostImages(oldz string, newz string)
- func DifferenceSets(a []string, b []string) []string
- func Elapse(f func()) int64
- func ElapseString(f func()) string
- func EncryptHash(password string, salt []byte) string
- func Exist(filename string) bool
- func File(s string) string
- func FileGetContent(file string) (string, error)
- func FileMTime(file string) (int64, error)
- func FilePutContent(file string, content string) (int, error)
- func FileSize(file string) (int64, error)
- func Filehash(pathOr string, fileOr *os.File) (string, error)
- func FilehashBlock(path string, block int64) string
- func FilehashNumber(path string) (int, error)
- func FixURL(currentURL, url string) string
- func FixedpathByNumber(n int, layer int) string
- func FixedpathByString(s string, layer int) string
- func GUID() string
- func GUID32BIT() string
- func GetBanner(content string) (string, error)
- func GetBannerThumbnail(content string) (string, error)
- func GetCurrentTimeFormat(format string) string
- func GetFile(fileURL string, filePath string, useragent string, referer string) error
- func GetImagePha(path string) (string, error)
- func GetImages(content string) (imgs []string, num int)
- func GetJsonCOMDecrypt(status string, actionurl string, data interface{}, ckJar *cookiejar.Jar) (*simplejson.Json, error)
- func GetMonthDays(year, month int) int
- func GetPage(url string) (string, error)
- func GetSensitiveInfoRemovedEmail(email string) string
- func GetThumbnails(content string) (thumbnails string, thumbnailslarge string, thumbnailsmedium string, ...)
- func GetTimeFormat(second int64, format string) string
- func GetTimestamp() int64
- func GetTimestampInMicro() int64
- func GetTimestampInMicroString() string
- func GetTimestampInMilli() int64
- func GetTimestampInMilliString() string
- func GetTimestampString() string
- func GetVideoAddress(input string) string
- func GraphicsProcess(r io.Reader, w io.Writer, width, height, quality int) error
- func Gravatar(email string, height int) string
- func HTML2str(html string) string
- func Hotness(ups, downs, createTime int64) float64
- func Htm2Str(htm string) string
- func Htmlquote(text string) string
- func Htmlunquote(text string) string
- func IntersectionSets(fora []string, forb []string) []string
- func IsContainsSets(values []string, ivalue string) bool
- func IsExist(path string) bool
- func IsFile(file string) bool
- func IsLeapYear(year int) bool
- func IsLocal(path string) bool
- func IsSendMail() (isSendMail bool)
- func IsSpider(userAgent string) bool
- func Local2url(path string) string
- func MD5(s string) string
- func MD5to16(s string) string
- func MakeThumbnails(localpath string) (thumbnails string, thumbnailslarge string, thumbnailsmedium string, ...)
- func Markdown(md string) template.HTML
- func Markdown2Byte(md string) []byte
- func Markdown2String(md string) string
- func Markdown2Text(md string) string
- func MarkdownByPongo2(in *pongo2.Value) *pongo2.Value
- func Metric(n int64) string
- func MoveFile(frompath string, topath string) error
- func Nrand(n int64) float64
- func ObjPolicy() *bluemonday.Policy
- func OrderKey(FUid, SUid int64) string
- func PHA(m image.Image) string
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func PKCS7Pad(data []byte) []byte
- func PKCS7Padding(data []byte) []byte
- func PKCS7UnPadding(data []byte) []byte
- func PKCS7Unpad(data []byte) []byte
- func Pages(totalRecords int64, page int64, pageSize int64) (pages int64, pageOutput int64, beginNum int64, endNum int64, offset int64)
- func Pagesbar(url string, keyword string, resultsMax int64, pages int64, page int64, ...) (output template.HTML)
- func PhaCompare(path1 string, path2 string) (int, error)
- func PingFile(url string) bool
- func PostFile(filepath string, actionurl string, fieldname string) (*http.Response, error)
- func PrintError()
- func PurePolicy() *bluemonday.Policy
- func Qhot(Qviews, Qanswers, Qscore, Ascores, Created, ReplyTime int64) float64
- func QhotAScore(ups int64, downs int64) int64
- func QhotQScore(ups int64, downs int64) int64
- func QhotVote(ups int64, downs int64) int64
- func RangeRand(n int) int
- func Rename(file string, to string) error
- func Resample(m image.Image, r image.Rectangle, w, h int) image.Image
- func Resize(m image.Image, r image.Rectangle, w, h int) image.Image
- func Rex(text string, iregexp string) (b bool)
- func Round(val float64, prec int) float64
- func RsaAesReceivingPacket(decrypt bool, hash string, status string, content []byte, aesPublicKey string, ...) ([]byte, error)
- func RsaAesSendPacket(encrypt bool, status string, actionurl string, content string, aesKey string, ...) (*http.Response, error)
- func RsaDecrypt(ciphertext []byte, privateKey []byte) ([]byte, error)
- func RsaEncrypt(origData []byte, publicKey []byte) ([]byte, error)
- func S2T(str string) string
- func SHA1(s string) string
- func Score(ups int64, downs int64) int64
- func SendEmail(to, subject, body, mailtype string) error
- func SendMail(user, password, host, to, subject, body, mailtype string) error
- func SendPacket(status string, actionurl string, content string, ckJar *cookiejar.Jar) (*http.Response, error)
- func SetJsonCOMEncrypt(status int64, msg string, data interface{}) (string, error)
- func SetSuffix(content string, str string) string
- func SmcTimeSince(timeAt time.Time) string
- func Split(content string, str string) []string
- func SplitByPongo2(in *pongo2.Value, splitor *pongo2.Value) *pongo2.Value
- func StandardURLsPolicy() *bluemonday.Policy
- func Str2Ans(str string) int64
- func Str2HTML(raw string) template.HTML
- func StrLen(str string) int64
- func StrOne(str string, where int64) string
- func StrPos(str string, sep string) int64
- func String2Time(strtime string) (time.Time, error)
- func String2UnixNano(strtime string) (int64, error)
- func StringNewRand(len int) string
- func StringNewUUID() string
- func StringToUTF16(s string) []uint16
- func Substr(strin string, start, length int, symbol string) string
- func SymmetricDifferenceSets(fora []string, forb []string) []string
- func T2S(str string) string
- func Tag4Video(input string) string
- func Theme() (theme string)
- func ThisDate() int64
- func ThisHour() int64
- func ThisMonth() int64
- func ThisWeek() int64
- func ThisYear() int64
- func Thumbnail(mode string, inputFile string, outputFile string, outputSize string, ...) error
- func TimeSince(timestamp int64) string
- func TouchFile(path string)
- func URL2local(path string) string
- func UnionSets(fora []string, forb []string) []string
- func Unix2Time(s int64, timeLayout string) string
- func Unix2TimeByPongo2(in *pongo2.Value, timeLayout *pongo2.Value) *pongo2.Value
- func UnixNS2Time(ns int64, timeLayout string) string
- func Unlink(file string) error
- func ValidateHash(hashed string, input_password string) bool
- func VerifyUserfile(path string, usr string) bool
- func VideoTags(in string) string
- func Watermark(watermarkFile string, inputFile string, outputFile string, outputAlign string) error
- func WriteFile(filepath string, content string) error
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- func ZeroUnPadding(origData []byte) []byte
- type FileRepos
Constants ¶
const ( DATE_TIME_FMT = "2006-01-02 15:04:05" DATE_FMT = "2006-01-02" TIME_FMT = "15:04:05" DATE_TIME_FMT_CN = "2006年01月02日 15时04分05秒" DATE_FMT_CN = "2006年01月02日" TIME_FMT_CN = "15时04分05秒" )
FMT_TYPE_NOMAL
const SecondInNano = 1000 * 1000 * 1000
Variables ¶
var ( SmtpHost = "smtp.163.com" SmtpPort = "25" MailUser = "yougamcom@163.com" //发送邮件的邮箱 MailPassword = "Me87ga88mRpasW" //发送邮件邮箱的密码 MailAdline = "yougam.Com • 分享、探索和创造的地方." )
var ( RsaPublicKey = []byte(` -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZsfv1qscqYdy4vY+P4e3cAtmv ppXQcRvrF1cB4drkv0haU24Y7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0Dgacd wYWd/7PeCELyEipZJL07Vro7Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NL AUeJ6PeW+DAkmJWF6QIDAQAB -----END PUBLIC KEY----- `) RsaPrivateKey = []byte(` -----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDZsfv1qscqYdy4vY+P4e3cAtmvppXQcRvrF1cB4drkv0haU24Y 7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0DgacdwYWd/7PeCELyEipZJL07Vro7 Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NLAUeJ6PeW+DAkmJWF6QIDAQAB AoGBAJlNxenTQj6OfCl9FMR2jlMJjtMrtQT9InQEE7m3m7bLHeC+MCJOhmNVBjaM ZpthDORdxIZ6oCuOf6Z2+Dl35lntGFh5J7S34UP2BWzF1IyyQfySCNexGNHKT1G1 XKQtHmtc2gWWthEg+S6ciIyw2IGrrP2Rke81vYHExPrexf0hAkEA9Izb0MiYsMCB /jemLJB0Lb3Y/B8xjGjQFFBQT7bmwBVjvZWZVpnMnXi9sWGdgUpxsCuAIROXjZ40 IRZ2C9EouwJBAOPjPvV8Sgw4vaseOqlJvSq/C/pIFx6RVznDGlc8bRg7SgTPpjHG 4G+M3mVgpCX1a/EU1mB+fhiJ2LAZ/pTtY6sCQGaW9NwIWu3DRIVGCSMm0mYh/3X9 DAcwLSJoctiODQ1Fq9rreDE5QfpJnaJdJfsIJNtX1F+L3YceeBXtW0Ynz2MCQBI8 9KP274Is5FkWkUFNKnuKUK4WKOuEXEO+LpR+vIhs7k6WQ8nGDd4/mujoJBr5mkrw DPwqA3N5TMNDQVGv8gMCQQCaKGJgWYgvo3/milFfImbp+m7/Y3vCptarldXrYQWO AQjxwc71ZGBFDITYvdgJM1MTqc8xQek1FXn1vfpy2c6O -----END RSA PRIVATE KEY----- `) Version = "4.0.3" AesKey = "jjsdj#$827gfgh38dakljzmknghsj#2k" //32位 AesPublicKey = "akljzmknm.ahkjkl" //16位 ConfigPath = "./conf/config.conf" //网站信息 Domain = "http://www.yougam.com" SiteName = "YOUGAM" SiteTitle = "YOUGAM - 记录分享探索世界的有趣轨迹" Keywords = "" /* 130-byte string literal not displayed */ Description = "优姬是一个记录生命旅途的每一分精彩和感动,珍藏美好的回忆,分享创造发现的地方.." //验证码 IsCaptcha = false //数据库设定 DataType = "goleveldb" DBConnect = "goleveldb://../yougam/data/tidb/tidb" //API通信常量密匙 AesConstKey = "Ks*x(" //5位 //七牛云存储 BUCKET4QINIU = "yougam" DOMAIN4QINIU = "7mnnte.com1.z0.glb.clouddn.com" AKEY4QINIU = "7hFd6CFkhjbtr74AgTlXZ7WgY4mpo4pmsTlyK37D" SKEY4QINIU = "F5EmL1X44LA-ypSIX1TUdZrpwxrDwUI2WiMnRVe6" //本地存储根路径设定 FileStorageDir = "../" //数据库表前缀设定 DBTablePrefix = "" )
Functions ¶
func AesCBCDecrypt ¶
AesCBCDecrypt AES256 解密CBC模式
func AesCBCEncrypt ¶
AesCBCEncrypt aes cbc encrypt AES-128,设key为 16 bytes. AES-192,设key为 24 bytes. AES-256,设key为 32 bytes. AES256 加密CBC模式
func AesCFBDecrypt ¶
AesCFBDecrypt AES256解密 CFB
func AesCFBEncrypt ¶
AesCFBEncrypt AES256加密 CFB
func AtPagesGetImages ¶
AtPagesGetImages 从网址的内容中提取图片
func Controversy ¶
//Reddit争议排序算法 譬如1000赞成+1000反对还是会比1赞成+0反对要靠前。
func ConvertToBase64 ¶
func ConvertToBase64ByPongo2 ¶
func ConvertToBase64ByPongo2(in *pongo2.Value) *pongo2.Value
func CropwordByPongo2 ¶
func CropwordByPongo2(in *pongo2.Value, start *pongo2.Value, length *pongo2.Value, symbol *pongo2.Value) *pongo2.Value
func DelLostImages ¶
DelLostImages delete the lost images
func ElapseString ¶
func ElapseString(f func()) string
Timing the cost of function call, unix nano was returned
func EncryptHash ¶
func FilePutContent ¶
FilePutContent 将指定内容写入指定文件
func FixedpathByNumber ¶
FixedpathByNumber is fixed path via number
func FixedpathByString ¶
FixedpathByString is fixed path via string
func GetBannerThumbnail ¶
GetBannerThumbnail 从内容获取banner
func GetJsonCOMDecrypt ¶
func GetMonthDays ¶
GetMonthDays return days of the month/year
func GetSensitiveInfoRemovedEmail ¶
GetSensitiveInfoRemovedEmail 获取 sensitive 信息
func GetThumbnails ¶
func GetThumbnails(content string) (thumbnails string, thumbnailslarge string, thumbnailsmedium string, thumbnailssmall string, err error)
GetThumbnails get thumbnails from the content
func GetTimeFormat ¶
func GetTimestampInMilliString ¶
func GetTimestampInMilliString() string
return 1441007112776 in millisecond
func GetVideoAddress ¶
GetVideoAddress 调用you-get命令对输入的视频网站网址进行抽取真实视频源网址
func GraphicsProcess ¶
GraphicsProcess 图像处理过程
func IntersectionSets ¶
IntersectionSets 交集
func IsContainsSets ¶
IsContainsSets if is contains then return true
func IsSendMail ¶
func IsSendMail() (isSendMail bool)
func MD5 ¶
MD5 对字符串进行md5哈希, 返回32位小写md5结果
func MD5(s string) string { h := md5.New() io.WriteString(h, s) return fmt.Sprintf("%x", h.Sum(nil)) }
func MakeThumbnails ¶
func MakeThumbnails(localpath string) (thumbnails string, thumbnailslarge string, thumbnailsmedium string, thumbnailssmall string, err error)
MakeThumbnails 对指定图片文件进行缩略处理
func MarkdownByPongo2 ¶
func MarkdownByPongo2(in *pongo2.Value) *pongo2.Value
func PKCS5Padding ¶
PKCS5Padding PKCS5 补码
func PKCS7Pad ¶
PKCS7Pad pads an byte array to be a multiple of 16 http://tools.ietf.org/html/rfc5652#section-6.3
func PKCS7Unpad ¶
PKCS7Unpad removes any potential PKCS7 padding added.
func Pages ¶
func Pages(totalRecords int64, page int64, pageSize int64) (pages int64, pageOutput int64, beginNum int64, endNum int64, offset int64)
Pages : 分页计算函数
func Pagesbar ¶
func Pagesbar(url string, keyword string, resultsMax int64, pages int64, page int64, beginNum int64, endNum int64, style int64) (output template.HTML)
Pagesbar : is for the html template
func QhotAScore ¶
func QhotQScore ¶
func Resample ¶
重新取样返回一个重采样本的图像切片r的副本。 返回的图像具有宽度w和高度h。 Resample returns a resampled copy of the image slice r of m. The returned image has width w and height h.
func Resize ¶
调整传回的图像片的R米的缩放副本。 返回的图像具有宽度w和高度h。 Resize returns a scaled copy of the image slice r of m. The returned image has width w and height h.
func RsaAesReceivingPacket ¶
func RsaAesReceivingPacket(decrypt bool, hash string, status string, content []byte, aesPublicKey string, rsaPublicKey []byte, rsaPrivateKey []byte) ([]byte, error)
RsaAesReceivingPacket 接受加密数据包
func RsaAesSendPacket ¶
func RsaAesSendPacket(encrypt bool, status string, actionurl string, content string, aesKey string, aesPublicKey string, rsaPublicKey []byte) (*http.Response, error)
RsaAesSendPacket 发送报文 是否加密 HTTP状态 动作URL 数据内容 RSA公匙
func RsaDecrypt ¶
RsaDecrypt RSA解密
func RsaEncrypt ¶
RsaEncrypt RSA加密
func SendMail ¶
* * user : example@example.com login smtp server user * password: xxxxx login smtp server password * host: smtp.example.com:port smtp.163.com:25 * to: example@example.com;example1@163.com;example2@sina.com.cn;... * subject:The subject of mail * body: The content of mail * mailtype: mail type html or text
func SendPacket ¶
func SendPacket(status string, actionurl string, content string, ckJar *cookiejar.Jar) (*http.Response, error)
SendPacket 发送报文
func SetJsonCOMEncrypt ¶
func SplitByPongo2 ¶
func SplitByPongo2(in *pongo2.Value, splitor *pongo2.Value) *pongo2.Value
func StandardURLsPolicy ¶
func StandardURLsPolicy() *bluemonday.Policy
StandardURLsPolicy 返回标准URL Policy对象
func String2UnixNano ¶
String2UnixNano 时间字符串转换为纳秒级的时间戳
func StringNewUUID ¶
func StringNewUUID() string
StringNewUUID generates a new UUID based on version 4.
func SymmetricDifferenceSets ¶
SymmetricDifferenceSets 对称差=并集-交集 即是 并集和交集的差集就是对称差
func Thumbnail ¶
func Thumbnail(mode string, inputFile string, outputFile string, outputSize string, outputAlign string, background string) error
Thumbnail 对图片进行缩略处理
func Unix2TimeByPongo2 ¶
func Unix2TimeByPongo2(in *pongo2.Value, timeLayout *pongo2.Value) *pongo2.Value
func UnixNS2Time ¶
UnixNS2Time 转换时间戳为时间字符串 单位为纳秒
func ValidateHash ¶
func VerifyUserfile ¶
VerifyUserfile verify the user file