How to get Windows display name in Go?

huangapple go评论70阅读模式
英文:

How to get Windows display name in Go?

问题

我正在尝试在Go语言中获取我的Windows用户名和显示名称。我尝试了user.Current().Name,但它返回的是显示名称,而不是在命令提示符中使用whoami返回的实际用户名。

英文:

I'm trying to get my Windows username and display name in Go. I tried user.Current().Name but that returns the display name, not the actual username returned by whoami in a command prompt.

答案1

得分: 1

原来,Name 是显示名称,而 Username 是实际的用户名(以 domain\username 格式)。

英文:

Turns out, Name is the display name, while Username is the actual username (in domain\username format).

huangapple
  • 本文由 发表于 2021年7月14日 05:39:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/68369594.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定