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

安装后,使用go -version报错 #85

Open
donghao8455 opened this issue Jan 7, 2023 · 2 comments
Open

安装后,使用go -version报错 #85

donghao8455 opened this issue Jan 7, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@donghao8455
Copy link

PS C:\Users\donghao\Desktop> g uninstall 1.18.9
Uninstalled go1.18.9

PS C:\Users\donghao\Desktop> g install 1.18.9
Computing checksum with SHA256
Checksums matched
Now using go1.18.9

PS C:\Users\donghao\Desktop> go -version
go: The term 'go' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

应该是软连接 没有创建成功,但是不知道哪里配置错误了,起码安装过程中没有报错,望指教

@donghao8455 donghao8455 added the bug Something isn't working label Jan 7, 2023
@voidint
Copy link
Owner

voidint commented Jan 8, 2023

使用的是哪个版本的Windows系统?Windows系统下创建软连接会优先调用mklink这个外部命令。我身边没有Windows设备,无法去验证,你手动调用 mklink 试着创建下软连接,一起排查下。

func mkSymlink(oldname, newname string) (err error) {
	if runtime.GOOS == "windows" {
		// Windows 10下无特权用户无法创建符号链接,优先调用mklink /j创建'目录联接'
		if err = exec.Command("cmd", "/c", "mklink", "/j", newname, oldname).Run(); err == nil {
			return nil
		}
	}
	return os.Symlink(oldname, newname)
}

@imjohnny
Copy link

imjohnny commented Mar 27, 2024

碰到类似问题 已解决,可以先看看g.exe所在目录有没有go文件夹的快捷方式图标,如果没有就看看你登录用户(一般是C:\Users\你本地的用户名\.g)有没有go目录,有的话设置GOROOT=C:\Users\你本地的用户名\.g\go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants