This example program creates a context using the context.WithCancel() method from the context package.
WithCancel
creates the context while returning a cancel function that can be called to prematurely cancel/end the context.
exec.CommandContext(ctx, ".\\test.exe", "e")
is exec.Command()
but with creating a context around the creation and execution of the sub process. Using that context, the execution of the sub process can now be ended prematurely.
The text.exe is another compiled and linked Go program, that just loops forever, printing "ENDLESS.." to the console.
As the example program calls cmd.Wait()
it waits for the sub process to end, either by it ending by itself od because of being killed by another system process.