Skip to content

os.exit(1) 的使用问题 #84

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

Closed
spiritLHLS opened this issue Apr 12, 2025 · 2 comments
Closed

os.exit(1) 的使用问题 #84

spiritLHLS opened this issue Apr 12, 2025 · 2 comments

Comments

@spiritLHLS
Copy link

spiritLHLS commented Apr 12, 2025

Is your feature request related to a problem? Please describe.
github.com/nxtrace/NTrace-core v1.3.7
我在我的程序依赖中导入了本项目,但由于
https://github.com/nxtrace/NTrace-V1/blob/main/wshandle/client.go
中存在很多 os.Exit(1) ,主要是 recreateWsConn 中获取不到token报错
2025/04/12 12:15:34 RetToken failed 3 times, please try again later
的时候,我以此项目为依赖集成开发一些东西的时候会直接使得整个程序退出,是否有更妥善的方式,只是异常退出而不是整个程序退出?os.Exit(1) 不会引发 panic,而是 直接终止当前程序的执行,我 recover() 拦截不了

Describe the solution you'd like
希望程序退出有一个可以被recover()拦截的方法,方便进行二次开发

Describe alternatives you've considered
项目在需要退出时使用 panic() 而不是 os.Exit(1)

Additional context

tsosunchia added a commit that referenced this issue Apr 13, 2025
#84
 要提交的变更:
	修改:     cmd/cmd.go
	修改:     go.mod
	修改:     go.sum
	修改:     wshandle/client.go
@tsosunchia
Copy link
Member

Commit 608a290

@spiritLHLS
Copy link
Author

非常感谢修改

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

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy