golang 创建属于自己的库

2020-04-26  本文已影响0人  顶尖少爷

在日常开发,我们都会用到别人写的第三方库,那么我们也可以把自己写的代码发布到github给别人使用

git clone https://github.com/startdusk/goutil.git
go mod init github.com/startdusk/goutil   # 使用和github.com上的路径做包名
package hash

import (
    "crypto/md5"
    "encoding/hex"
)

/**
* @Title StringMd5
* @Description:   字符串md5加密
* @Param:
* @return:
* @Author: liwei
* @Date: 2020/4/24
**/
func StringMd5(s string) string{
    md5S :=md5.New()
    md5S.Write([]byte(s))
    return hex.EncodeToString(md5S.Sum(nil))
}

git add .
git commit -m "Add a md5 functions"
git push
go get github.com/startdusk/goutil
上一篇 下一篇

猜你喜欢

热点阅读