golang 按任意键继续

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/CodyGuo/article/details/51736946
package main

import (
	"fmt"
)

import (
	termbox "github.com/nsf/termbox-go"
)

func init() {
	if err := termbox.Init(); err != nil {
		panic(err)
	}
	termbox.SetCursor(0, 0)
	termbox.HideCursor()
}

func main() {
	fmt.Println("hello")
	pause()
	fmt.Println("world.")
}

func pause() {
	fmt.Println("请按任意键继续...")
Loop:
	for {
		switch ev := termbox.PollEvent(); ev.Type {
		case termbox.EventKey:
			break Loop
		}
	}
}

猜你喜欢

转载自blog.csdn.net/CodyGuo/article/details/51736946