A
A
Ao2019-04-17 09:59:13
go
Ao, 2019-04-17 09:59:13

How to open a terminal in Go when starting a program?

What should be written in the program so that when double-clicking on the executable file, the terminal opens and the program displays messages in it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hOtRush, 2019-04-17
@hOtRush

The terminal is a third-party application that has nothing to do with the execution of the program, and it is also unlikely that it will be able to display messages there.
When you run a Go binary from a terminal, that terminal simply captures its stdout. When you open a terminal from an application, this terminal has nothing to intercept, because the application is launched from a different environment. You can, of course, first run the binary, which will open a terminal and run another binary in that terminal. Though I could be wrong of course.)
a88.jpg

B
bodrich, 2019-04-17
@bodrich

If simple terminal screen output, then fmt.Println()

package main

import (
  "fmt"
)

func main() {
  fmt.Println("Hello world!")
}

K
Konstantin Tsvetkov, 2019-04-17
@tsklab

And so?

import "os"
import "fmt"

fmt.Fprintf(os.Stdout, "your message here");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question