get rid of interface{} since we now require Go 1.18

This commit is contained in:
Kovid Goyal 2022-09-21 08:11:46 +05:30
parent a44c89504b
commit 2cacd7a64a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
15 changed files with 37 additions and 37 deletions

View File

@ -152,7 +152,7 @@ def generate_completions_for_kitty() -> None:
# rc command wrappers {{{
json_field_types: Dict[str, str] = {
'bool': 'bool', 'str': 'string', 'list.str': '[]string', 'dict.str': 'map[string]string', 'float': 'float64', 'int': 'int',
'scroll_amount': 'interface{}', 'spacing': 'interface{}', 'colors': 'interface{}',
'scroll_amount': 'any', 'spacing': 'any', 'colors': 'any',
}

View File

@ -52,7 +52,7 @@ func is_string_slice(f reflect.Value) bool {
return f.Type().Elem().Kind() == reflect.String
}
func OptionsFromStruct(pointer_to_options_struct interface{}) ([]*Option, error) {
func OptionsFromStruct(pointer_to_options_struct any) ([]*Option, error) {
val := reflect.ValueOf(pointer_to_options_struct).Elem()
if val.Kind() != reflect.Struct {
return nil, fmt.Errorf("Need a pointer to a struct to set option values on")
@ -105,7 +105,7 @@ func option_from_string(overrides map[string]string, entries ...string) (*Option
}
ans := Option{
values_from_cmdline: make([]string, 0, 1),
parsed_values_from_cmdline: make([]interface{}, 0, 1),
parsed_values_from_cmdline: make([]any, 0, 1),
}
scanner := utils.NewScanLines(entries...)
in_help := false

View File

@ -50,8 +50,8 @@ type Option struct {
Parent *Command
values_from_cmdline []string
parsed_values_from_cmdline []interface{}
parsed_default interface{}
parsed_values_from_cmdline []any
parsed_default any
seen_option string
}
@ -79,7 +79,7 @@ func NormalizeOptionName(name string) string {
return strings.ReplaceAll(strings.TrimLeft(name, "-"), "_", "-")
}
func (self *Option) parsed_value() interface{} {
func (self *Option) parsed_value() any {
if len(self.values_from_cmdline) == 0 {
return self.parsed_default
}
@ -96,7 +96,7 @@ func (self *Option) parsed_value() interface{} {
}
}
func (self *Option) parse_value(val string) (interface{}, error) {
func (self *Option) parse_value(val string) (any, error) {
switch self.OptionType {
case BoolOption:
switch val {
@ -455,7 +455,7 @@ type Context struct {
SeenCommands []*Command
}
func (self *Command) GetOptionValues(pointer_to_options_struct interface{}) error {
func (self *Command) GetOptionValues(pointer_to_options_struct any) error {
m := make(map[string]*Option, 128)
for _, g := range self.OptionGroups {
for _, o := range g.Options {

View File

@ -83,7 +83,7 @@ func simple_serializer(rc *utils.RemoteControlCmd) (ans []byte, err error) {
type serializer_func func(rc *utils.RemoteControlCmd) ([]byte, error)
func debug_to_log(args ...interface{}) {
func debug_to_log(args ...any) {
f, err := os.OpenFile("/tmp/kdlog", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
if err == nil {
fmt.Fprintln(f, args...)

View File

@ -8,8 +8,8 @@ import (
"strings"
)
func parse_scroll_amount(amt string) ([]interface{}, error) {
var ans = make([]interface{}, 2)
func parse_scroll_amount(amt string) ([]any, error) {
var ans = make([]any, 2)
if amt == "start" || amt == "end" {
ans[0] = amt
ans[1] = nil

View File

@ -26,7 +26,7 @@ var nullable_colors = map[string]bool{
// NULLABLE_COLORS_END
}
func set_color_in_color_map(key, val string, ans map[string]interface{}, check_nullable, skip_nullable bool) error {
func set_color_in_color_map(key, val string, ans map[string]any, check_nullable, skip_nullable bool) error {
if val == "none" {
if check_nullable && !nullable_colors[key] {
if skip_nullable {
@ -45,8 +45,8 @@ func set_color_in_color_map(key, val string, ans map[string]interface{}, check_n
return nil
}
func parse_colors_and_files(args []string) (map[string]interface{}, error) {
ans := make(map[string]interface{}, len(args))
func parse_colors_and_files(args []string) (map[string]any, error) {
ans := make(map[string]any, len(args))
for _, arg := range args {
key, val, found := utils.Cut(strings.ToLower(arg), "=")
if found {

View File

@ -10,8 +10,8 @@ import (
"kitty/tools/utils"
)
func parse_set_spacing(args []string) (map[string]interface{}, error) {
ans := make(map[string]interface{}, len(args))
func parse_set_spacing(args []string) (map[string]any, error) {
ans := make(map[string]any, len(args))
mapper := make(map[string][]string, 32)
types := [2]string{"margin", "padding"}
for _, q := range types {

View File

@ -11,8 +11,8 @@ import (
var valid_color_names = map[string]bool{"active_fg": true, "active_bg": true, "inactive_fg": true, "inactive_bg": true}
func parse_tab_colors(args []string) (map[string]interface{}, error) {
ans := make(map[string]interface{}, len(args))
func parse_tab_colors(args []string) (map[string]any, error) {
ans := make(map[string]any, len(args))
for _, arg := range args {
key, val, found := utils.Cut(strings.ToLower(arg), "=")
if !found {

View File

@ -13,7 +13,7 @@ var _ = fmt.Print
func bash_output_serializer(completions []*Completions, shell_state map[string]string) ([]byte, error) {
output := strings.Builder{}
f := func(format string, args ...interface{}) { fmt.Fprintf(&output, format+"\n", args...) }
f := func(format string, args ...any) { fmt.Fprintf(&output, format+"\n", args...) }
n := completions[0].Delegate.NumToRemove
if n > 0 {
f("compopt +o nospace")

View File

@ -14,7 +14,7 @@ var _ = fmt.Print
func fish_output_serializer(completions []*Completions, shell_state map[string]string) ([]byte, error) {
output := strings.Builder{}
f := func(format string, args ...interface{}) { fmt.Fprintf(&output, format+"\n", args...) }
f := func(format string, args ...any) { fmt.Fprintf(&output, format+"\n", args...) }
n := completions[0].Delegate.NumToRemove
fm := markup.New(false) // fish freaks out if there are escape codes in the description strings
if n > 0 {

View File

@ -15,11 +15,11 @@ import (
"kitty/tools/utils"
)
func debug(args ...interface{}) {
func debug(args ...any) {
tty.DebugPrintln(args...)
}
func debugf(format string, args ...interface{}) {
func debugf(format string, args ...any) {
debug(fmt.Sprintf(format, args...))
}

View File

@ -278,7 +278,7 @@ func (self *Term) WriteString(b string) (int, error) {
return self.os_file.WriteString(b)
}
func (self *Term) DebugPrintln(a ...interface{}) {
func (self *Term) DebugPrintln(a ...any) {
msg := []byte(fmt.Sprintln(a...))
const limit = 2048
encoded := make([]byte, limit*2)
@ -308,7 +308,7 @@ func (self *Term) GetSize() (*unix.Winsize, error) {
// go doesnt have a wrapper for ctermid()
func Ctermid() string { return "/dev/tty" }
func DebugPrintln(a ...interface{}) {
func DebugPrintln(a ...any) {
term, err := OpenControllingTerm()
if err == nil {
defer term.Close()

View File

@ -139,7 +139,7 @@ func (self *Loop) KillIfSignalled() {
}
}
func (self *Loop) DebugPrintln(args ...interface{}) {
func (self *Loop) DebugPrintln(args ...any) {
if self.controlling_term != nil {
const limit = 2048
msg := fmt.Sprintln(args...)

View File

@ -11,11 +11,11 @@ type Context struct {
AllowEscapeCodes bool
}
func (self *Context) SprintFunc(spec string) func(args ...interface{}) string {
func (self *Context) SprintFunc(spec string) func(args ...any) string {
p := prefix_for_spec(spec)
s := suffix_for_spec(spec)
return func(args ...interface{}) string {
return func(args ...any) string {
body := fmt.Sprint(args...)
if !self.AllowEscapeCodes {
return body

View File

@ -3,16 +3,16 @@
package utils
type RemoteControlCmd struct {
Cmd string `json:"cmd"`
Version [3]int `json:"version"`
NoResponse bool `json:"no_response,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Password string `json:"password,omitempty"`
Async string `json:"async,omitempty"`
CancelAsync bool `json:"cancel_async,omitempty"`
Stream bool `json:"stream,omitempty"`
StreamId string `json:"stream_id,omitempty"`
Payload interface{} `json:"payload,omitempty"`
Cmd string `json:"cmd"`
Version [3]int `json:"version"`
NoResponse bool `json:"no_response,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Password string `json:"password,omitempty"`
Async string `json:"async,omitempty"`
CancelAsync bool `json:"cancel_async,omitempty"`
Stream bool `json:"stream,omitempty"`
StreamId string `json:"stream_id,omitempty"`
Payload any `json:"payload,omitempty"`
}
type EncryptedRemoteControlCmd struct {