使用Golang打开默认的Windows文本编辑器来打开txt文件。

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

Opening txt files with default windows text editor in golang

问题

我想使用默认的文本编辑器应用程序打开txt文件,但我不知道Windows存储应用程序和文件格式关联的位置。例如,在类Unix系统中,有一个名为$EDITOR的环境变量,用于存储默认编辑器的路径。

我进行了很多研究,但是找不到任何信息。

提前感谢。

英文:

I want to open txt files using default text editor application that set for, but I don't know where windows stores the application and file format associative. for example in Unix-like systems there is an enjoinment variable called $EDITOR that stores the path to default editor.

I did a lot of research but I couldn't find anything

thanks in advance

答案1

得分: 2

我找到了如何在Windows中使用默认应用程序打开文件的方法。你只需要打开文件本身即可。看一下下面的示例:

    exec.Command("cmd", "/c", "sample.txt")
英文:

I figure out how to open files with default apps in windows. All the things you need to do is opening file by its own. take a look at below example.

    exec.Command("cmd", "/c", "sample.txt")

huangapple
  • 本文由 发表于 2023年5月15日 23:56:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76255893.html
匿名

发表评论

匿名网友

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

确定