Search code examples
windowsgocmd

Opening txt files with default windows text editor in golang


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


Solution

  • 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")