Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: find default IP segment file at the location of the executable #401

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

scientificworld
Copy link

May fix #372.

Copy link
Contributor

@charSLee013 charSLee013 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

个人一些小小的建议

task/ip.go Outdated
if err != nil {
log.Fatal(err)
}
return filepath.Dir(sym) + "/ip.txt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

路径拼接改为 filepath.Join(sym, defaultInputFile) 在兼容性会不会更好一点?

task/ip.go Outdated
Comment on lines 177 to 180
} else { // 从文件中获取 IP 段数据
if IPFile == "" {
IPFile = defaultInputFile
IPFile = getDefaultInputFile()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

限制住IP文件只能跟执行文件在一起可能不太友好,可以先从当前工作目录下寻找defaultInputFile,如果找不到再考虑执行文件所在的目录下

下面是我粗略的改法,仅供参考

	} else { // 检查默认目录下是否存在IP文件
		if IPFile == "" {
			// 优先检查工作目录下的IP文件
			if _,err:= os.Stat(defaultInputFile); err != nil {
				IPFile = getDefaultInputFile();
			} else {
				IPFile = defaultInputFile
			}
		}

@scientificworld
Copy link
Author

已修改。没学过 golang,不太会写😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS 支持M芯片使用 homebrew 安装
2 participants