diff --git a/Software/Development/Language/Go/Basic/File/Gloang_文件操作.md b/Software/Development/Language/Go/Basic/File/Gloang_文件操作.md index 5159017..3db6682 100644 --- a/Software/Development/Language/Go/Basic/File/Gloang_文件操作.md +++ b/Software/Development/Language/Go/Basic/File/Gloang_文件操作.md @@ -255,16 +255,22 @@ func ListDir(dir, suffix string) (files []string, err error) { suffix = strings.ToLower(suffix) //匹配后缀 - for _, _file := range _dir { - if _file.IsDir() { - continue //忽略目录 + for _, file := range _dir { + if file.IsDir() { + // 递归读取子目录下的文件 + sub := filepath.Join(dir, file.Name()) + fs, err := ListDir(sub, suffix) + if len(fs) != 0 && err == nil { + files = append(files, fs...) + } + continue } if len(suffix) == 0 { // 不需要匹配文件后缀 - files = append(files, filepath.Join(dir, _file.Name())) - } else if strings.HasSuffix(strings.ToLower(_file.Name()), suffix) { + files = append(files, filepath.Join(dir, file.Name())) + } else if strings.HasSuffix(strings.ToLower(file.Name()), suffix) { // 文件后缀匹配 - files = append(files, filepath.Join(dir, _file.Name())) + files = append(files, filepath.Join(dir, file.Name())) } } diff --git a/Software/Development/Language/Go/Package/Go_包的创建和使用.md b/Software/Development/Language/Go/Package/Go_包的创建和使用.md index 23b2ac9..35478be 100644 --- a/Software/Development/Language/Go/Package/Go_包的创建和使用.md +++ b/Software/Development/Language/Go/Package/Go_包的创建和使用.md @@ -104,7 +104,7 @@ import ( I published an update to a Go module, bumping the version to v1.1.0. I created a tag named v1.1.0 and pushed the tag to GitHub. -https://github.com/depp/bytesize/releases/tag/v1.1.0 + However, I cannot use this package in my other projects. I get an error that says, "invalid version: unknown revision v1.1.0". I don't know why the revision is "unknown", since it's tagged. @@ -122,22 +122,24 @@ The tag was pushed after invoking go get once, which poisoned the Go module prox From : - Note that if someone requested the version before the tag was pushed, it may take up to 30 minutes for the mirror's cache to expire and fresh data about the version to become available. +```txt +Note that if someone requested the version before the tag was pushed, it may take up to 30 minutes for the mirror's cache to expire and fresh data about the version to become available. +``` The way to work around this before the cache expires is to use the GOPRIVATE environment variable to instruct go get to fetch this module directly, bypassing the cache. From : - GOPRIVATE, GONOPROXY, GONOSUMDB +```txt +GOPRIVATE, GONOPROXY, GONOSUMDB - Comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes that should always be fetched directly or that should not be compared against the checksum database. +Comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes that should always be fetched directly or that should not be compared against the checksum database. +``` The workaround is: ```bash -$ GOPRIVATE=github.com/depp/bytesize go get github.com/depp/bytesize@v1.1.0 +GOPRIVATE=github.com/depp/bytesize go get github.com/depp/bytesize@v1.1.0 ``` Note that if you are already using GOPRIVATE, you will want to add modules rather than overriding the value completely. - - diff --git a/Software/Development/Language/Go/Package/Path/Golang_处理文件和目录路径.md b/Software/Development/Language/Go/Package/Path/Golang_处理文件和目录路径.md index 68adeda..97c59a2 100644 --- a/Software/Development/Language/Go/Package/Path/Golang_处理文件和目录路径.md +++ b/Software/Development/Language/Go/Package/Path/Golang_处理文件和目录路径.md @@ -90,7 +90,7 @@ filepath.Match("/home/catch/*", "/home/catch/foo/bar") ```go /** - * 获取主文件名嗯 + * 获取主文件名 * 输出:my.demo */ filename := "my.demo.jpg"