tcell
is pretty nice to usekill -9 $(pidof path/to/program)
is pretty controlled way to stop a programSIGUSR1
for status and SIGTERM
for stop both of which you can catchchan
chan
func main() {
inputChan := make(chan string)
go func() {
defer close(inputChan)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
inputChan <- scanner.Text()
}
}()
// Main loop
for {
select {
case input, ok := <-inputChan:
if ok {
fmt.Println("received command: ", input)
} else {
return
}
default:
// Do whatever
}
}
}
This is about what I had in mind (edited)func main() {
inputChan := make(chan string)
go func() {
defer close(inputChan)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
inputChan <- scanner.Text()
}
}()
// Main loop
for {
select {
case input, ok := <-inputChan:
if ok {
fmt.Println("received command: ", input)
} else {
return
}
default:
// Do whatever
}
}
}
This is about what I had in mind (edited)tcell
or sth