Home  >  Article  >  Backend Development  >  Open txt file using default windows text editor in golang

Open txt file using default windows text editor in golang

WBOY
WBOYforward
2024-02-06 11:27:13493browse

Open txt file using default windows text editor in golang

Question content

I want to open a txt file using the set default text editor application, but I don't know where Windows stores applications and files Format association. For example, in Unix-like systems, there is a command variable called $EDITOR that stores the path to the default editor.

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

Thanks in Advance


Correct Answer


I figured out how to open a file in windows using the default application. All you need to do is open the file yourself. Take a look at the example below.

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

The above is the detailed content of Open txt file using default windows text editor in golang. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete