-
Notifications
You must be signed in to change notification settings - Fork 3
JA02_デフォルトのテキストとカーソル位置
HAYAMA_Kaoru edited this page Oct 11, 2023
·
1 revision
起動時にあらかじめデフォルト値を格納しておくことが可能です。
package main
import (
"context"
"fmt"
"github.com/nyaosorg/go-readline-ny"
)
func main() {
var editor readline.Editor
editor.Default = "前回の値"
editor.Cursor = 2
text, err := editor.ReadLine(context.Background())
if err != nil {
fmt.Printf("ERR=%s\n", err.Error())
} else {
fmt.Printf("TEXT=%s\n", text)
}
}
これで実行すると、デフォルト値として「前回の値」が入り、カーソルは0から数えた2文字目、つまり1から数えた3文字目の位置で点滅します。