需要使用GO中的转义序列的帮助

问题描述 投票:0回答:1

我正在尝试使转义序列在Go应用程序中工作。特别是用于移动光标的代码。fmt.Printf("\033[3;5H")为了使这项工作有效,我应该打印/写些什么?还是我完全以错误的方式来处理?每次运行代码时,终端中都会出现一些看起来很时髦的字符,否则什么也没有发生。我正在运行Windows 10。

我尝试使用多个不同的fmt.Print函数,但得到的结果相同。

// Move the cursor
fmt.Printf("\033[3;5H")

// Print at new position
fmt.Printf("Print this text at the new cursor position")
go escaping octal
1个回答
0
投票

结果您需要在Windows 10中启用虚拟终端处理才能使用ANSII转义码

https://github.com/konsorten/go-windows-terminal-sequences

© www.soinside.com 2019 - 2024. All rights reserved.