📝 add notes

This commit is contained in:
微凉
2021-02-04 10:02:34 +08:00
parent 3b2a729dc6
commit e146054679
26 changed files with 91 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
)
// get code from url
func GetCode(rawUrl string) string {
u,err:=url.Parse(rawUrl)
if err!=nil {
@@ -17,6 +18,7 @@ func GetCode(rawUrl string) string {
return code
}
// determine whether to include
func ContainsString(array []string, val string) (index int) {
index = -1
for i := 0; i < len(array); i++ {
@@ -28,6 +30,7 @@ func ContainsString(array []string, val string) (index int) {
return
}
// compare version
func VersionCompare(version1, version2 string) int {
a := strings.Split(version1, ".")
b := strings.Split(version2, ".")

View File

@@ -8,6 +8,7 @@ import (
"path/filepath"
)
// determine whether the file exists
func Exists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
@@ -17,6 +18,7 @@ func Exists(name string) bool {
return true
}
// 嵌套创建文件
func CreatNestedFile(path string) (*os.File, error) {
basePath := filepath.Dir(path)
if !Exists(basePath) {
@@ -29,6 +31,7 @@ func CreatNestedFile(path string) (*os.File, error) {
return os.Create(path)
}
// write struct to yaml file
func WriteToYml(src string,conf interface{}){
data,err := yaml.Marshal(conf)
if err!=nil {