From 35c20326c592754e3343584b02b5c0c9a2454979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:01:35 +0100 Subject: [PATCH 1/5] rtfiles: Initialize all-/realFiles and Plugins in InitRuntimeFiles --- internal/config/rtfiles.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/config/rtfiles.go b/internal/config/rtfiles.go index 275831cf7..d20162af4 100644 --- a/internal/config/rtfiles.go +++ b/internal/config/rtfiles.go @@ -40,8 +40,13 @@ var allFiles [][]RuntimeFile var realFiles [][]RuntimeFile func init() { + initRuntimeVars() +} + +func initRuntimeVars() { allFiles = make([][]RuntimeFile, NumTypes) realFiles = make([][]RuntimeFile, NumTypes) + Plugins = Plugins[:0] } // NewRTFiletype creates a new RTFiletype @@ -173,6 +178,8 @@ func InitRuntimeFiles() { AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern) } + initRuntimeVars() + add(RTColorscheme, "colorschemes", "*.micro") add(RTSyntax, "syntax", "*.yaml") add(RTSyntaxHeader, "syntax", "*.hdr") From 1b08d2cabe650939413aa578970763c704a60c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:35:19 +0100 Subject: [PATCH 2/5] command: Reload plugins at ReloadCmd too --- internal/action/command.go | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/internal/action/command.go b/internal/action/command.go index e241d687d..352f3c0cb 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -329,12 +329,17 @@ func (h *BufPane) ToggleLogCmd(args []string) { } } -// ReloadCmd reloads all files (syntax files, colorschemes...) +// ReloadCmd reloads all files (syntax files, colorschemes, plugins...) func (h *BufPane) ReloadCmd(args []string) { - ReloadConfig() + reloadRuntime(true) } +// ReloadConfig reloads only the configuration func ReloadConfig() { + reloadRuntime(false) +} + +func reloadRuntime(reloadAll bool) { config.InitRuntimeFiles() err := config.ReadSettings() if err != nil { @@ -344,14 +349,40 @@ func ReloadConfig() { if err != nil { screen.TermMessage(err) } + + if reloadAll { + err = config.RunPluginFn("deinit") + if err != nil { + screen.TermMessage(err) + } + err = config.LoadAllPlugins() + if err != nil { + screen.TermMessage(err) + } + } + InitBindings() InitCommands() + if reloadAll { + err = config.RunPluginFn("preinit") + if err != nil { + screen.TermMessage(err) + } + err = config.RunPluginFn("init") + if err != nil { + screen.TermMessage(err) + } + err = config.RunPluginFn("postinit") + if err != nil { + screen.TermMessage(err) + } + } + err = config.InitColorscheme() if err != nil { screen.TermMessage(err) } - for _, b := range buffer.OpenBuffers { b.UpdateRules() } From e4a2787636184c666249546293514a6f37616972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 18 Mar 2024 23:02:12 +0100 Subject: [PATCH 3/5] command: Don't reload plugins in case of ReloadConfig() --- cmd/micro/micro.go | 2 +- cmd/micro/micro_test.go | 2 +- internal/action/command.go | 14 ++-- internal/buffer/settings.go | 4 +- internal/config/rtfiles.go | 134 ++++++++++++++++---------------- internal/config/rtfiles_test.go | 2 +- 6 files changed, 83 insertions(+), 75 deletions(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 8be2bfbd9..71a601640 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -254,7 +254,7 @@ func main() { screen.TermMessage(err) } - config.InitRuntimeFiles() + config.InitRuntimeFiles(true) err = config.ReadSettings() if err != nil { screen.TermMessage(err) diff --git a/cmd/micro/micro_test.go b/cmd/micro/micro_test.go index ba5c9a24b..d00be32e6 100644 --- a/cmd/micro/micro_test.go +++ b/cmd/micro/micro_test.go @@ -35,7 +35,7 @@ func startup(args []string) (tcell.SimulationScreen, error) { return nil, err } - config.InitRuntimeFiles() + config.InitRuntimeFiles(true) err = config.ReadSettings() if err != nil { return nil, err diff --git a/internal/action/command.go b/internal/action/command.go index 352f3c0cb..0c537df18 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -340,7 +340,15 @@ func ReloadConfig() { } func reloadRuntime(reloadAll bool) { - config.InitRuntimeFiles() + if reloadAll { + err := config.RunPluginFn("deinit") + if err != nil { + screen.TermMessage(err) + } + } + + config.InitRuntimeFiles(reloadAll) + err := config.ReadSettings() if err != nil { screen.TermMessage(err) @@ -351,10 +359,6 @@ func reloadRuntime(reloadAll bool) { } if reloadAll { - err = config.RunPluginFn("deinit") - if err != nil { - screen.TermMessage(err) - } err = config.LoadAllPlugins() if err != nil { screen.TermMessage(err) diff --git a/internal/buffer/settings.go b/internal/buffer/settings.go index ce9abf3ec..1bc2ba0b1 100644 --- a/internal/buffer/settings.go +++ b/internal/buffer/settings.go @@ -20,7 +20,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error { } else if option == "statusline" { screen.Redraw() } else if option == "filetype" { - config.InitRuntimeFiles() + config.InitRuntimeFiles(false) err := config.ReadSettings() if err != nil { screen.TermMessage(err) @@ -74,7 +74,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error { } } } - } + } if b.OptionCallback != nil { b.OptionCallback(option, nativeValue) diff --git a/internal/config/rtfiles.go b/internal/config/rtfiles.go index d20162af4..fed6e5069 100644 --- a/internal/config/rtfiles.go +++ b/internal/config/rtfiles.go @@ -40,13 +40,15 @@ var allFiles [][]RuntimeFile var realFiles [][]RuntimeFile func init() { - initRuntimeVars() + initRuntimeVars(true) } -func initRuntimeVars() { +func initRuntimeVars(reloadAll bool) { allFiles = make([][]RuntimeFile, NumTypes) realFiles = make([][]RuntimeFile, NumTypes) - Plugins = Plugins[:0] + if reloadAll { + Plugins = Plugins[:0] + } } // NewRTFiletype creates a new RTFiletype @@ -172,86 +174,47 @@ func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile { } // InitRuntimeFiles initializes all assets file and the config directory -func InitRuntimeFiles() { +func InitRuntimeFiles(reloadAll bool) { add := func(fileType RTFiletype, dir, pattern string) { AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern) AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern) } - initRuntimeVars() + initRuntimeVars(reloadAll) add(RTColorscheme, "colorschemes", "*.micro") add(RTSyntax, "syntax", "*.yaml") add(RTSyntaxHeader, "syntax", "*.hdr") add(RTHelp, "help", "*.md") - initlua := filepath.Join(ConfigDir, "init.lua") - if _, err := os.Stat(initlua); !os.IsNotExist(err) { - p := new(Plugin) - p.Name = "initlua" - p.DirName = "initlua" - p.Srcs = append(p.Srcs, realFile(initlua)) - Plugins = append(Plugins, p) - } - - // Search ConfigDir for plugin-scripts - plugdir := filepath.Join(ConfigDir, "plug") - files, _ := ioutil.ReadDir(plugdir) - - isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString - - for _, d := range files { - plugpath := filepath.Join(plugdir, d.Name()) - if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() { - srcs, _ := ioutil.ReadDir(plugpath) + if reloadAll { + initlua := filepath.Join(ConfigDir, "init.lua") + if _, err := os.Stat(initlua); !os.IsNotExist(err) { p := new(Plugin) - p.Name = d.Name() - p.DirName = d.Name() - for _, f := range srcs { - if strings.HasSuffix(f.Name(), ".lua") { - p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, d.Name(), f.Name()))) - } else if strings.HasSuffix(f.Name(), ".json") { - data, err := ioutil.ReadFile(filepath.Join(plugdir, d.Name(), f.Name())) - if err != nil { - continue - } - p.Info, err = NewPluginInfo(data) - if err != nil { - continue - } - p.Name = p.Info.Name - } - } - - if !isID(p.Name) || len(p.Srcs) <= 0 { - log.Println(p.Name, "is not a plugin") - continue - } + p.Name = "initlua" + p.DirName = "initlua" + p.Srcs = append(p.Srcs, realFile(initlua)) Plugins = append(Plugins, p) } - } - plugdir = filepath.Join("runtime", "plugins") - if files, err := rt.AssetDir(plugdir); err == nil { - outer: - for _, d := range files { - for _, p := range Plugins { - if p.Name == d { - log.Println(p.Name, "built-in plugin overridden by user-defined one") - continue outer - } - } + // Search ConfigDir for plugin-scripts + plugdir := filepath.Join(ConfigDir, "plug") + files, _ := ioutil.ReadDir(plugdir) + + isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString - if srcs, err := rt.AssetDir(filepath.Join(plugdir, d)); err == nil { + for _, d := range files { + plugpath := filepath.Join(plugdir, d.Name()) + if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() { + srcs, _ := ioutil.ReadDir(plugpath) p := new(Plugin) - p.Name = d - p.DirName = d - p.Default = true + p.Name = d.Name() + p.DirName = d.Name() for _, f := range srcs { - if strings.HasSuffix(f, ".lua") { - p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f))) - } else if strings.HasSuffix(f, ".json") { - data, err := rt.Asset(filepath.Join(plugdir, d, f)) + if strings.HasSuffix(f.Name(), ".lua") { + p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, d.Name(), f.Name()))) + } else if strings.HasSuffix(f.Name(), ".json") { + data, err := ioutil.ReadFile(filepath.Join(plugdir, d.Name(), f.Name())) if err != nil { continue } @@ -262,6 +225,7 @@ func InitRuntimeFiles() { p.Name = p.Info.Name } } + if !isID(p.Name) || len(p.Srcs) <= 0 { log.Println(p.Name, "is not a plugin") continue @@ -269,6 +233,46 @@ func InitRuntimeFiles() { Plugins = append(Plugins, p) } } + + plugdir = filepath.Join("runtime", "plugins") + if files, err := rt.AssetDir(plugdir); err == nil { + outer: + for _, d := range files { + for _, p := range Plugins { + if p.Name == d { + log.Println(p.Name, "built-in plugin overridden by user-defined one") + continue outer + } + } + + if srcs, err := rt.AssetDir(filepath.Join(plugdir, d)); err == nil { + p := new(Plugin) + p.Name = d + p.DirName = d + p.Default = true + for _, f := range srcs { + if strings.HasSuffix(f, ".lua") { + p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f))) + } else if strings.HasSuffix(f, ".json") { + data, err := rt.Asset(filepath.Join(plugdir, d, f)) + if err != nil { + continue + } + p.Info, err = NewPluginInfo(data) + if err != nil { + continue + } + p.Name = p.Info.Name + } + } + if !isID(p.Name) || len(p.Srcs) <= 0 { + log.Println(p.Name, "is not a plugin") + continue + } + Plugins = append(Plugins, p) + } + } + } } } diff --git a/internal/config/rtfiles_test.go b/internal/config/rtfiles_test.go index de6525ef2..8b3f23d2a 100644 --- a/internal/config/rtfiles_test.go +++ b/internal/config/rtfiles_test.go @@ -7,7 +7,7 @@ import ( ) func init() { - InitRuntimeFiles() + InitRuntimeFiles(true) } func TestAddFile(t *testing.T) { From 0ae26bdc9d1e5fa138f0ebe8702406b56081f7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:20:57 +0100 Subject: [PATCH 4/5] rtfiles: Split InitRuntimeFiles() into one func for assets and one for plugins --- cmd/micro/micro.go | 4 +- cmd/micro/micro_test.go | 4 +- internal/action/command.go | 14 ++-- internal/buffer/settings.go | 2 +- internal/config/rtfiles.go | 138 ++++++++++++++++---------------- internal/config/rtfiles_test.go | 3 +- 6 files changed, 87 insertions(+), 78 deletions(-) diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 71a601640..bc6783412 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -254,7 +254,9 @@ func main() { screen.TermMessage(err) } - config.InitRuntimeFiles(true) + config.InitRuntimeFiles() + config.InitPlugins() + err = config.ReadSettings() if err != nil { screen.TermMessage(err) diff --git a/cmd/micro/micro_test.go b/cmd/micro/micro_test.go index d00be32e6..7ee521cb7 100644 --- a/cmd/micro/micro_test.go +++ b/cmd/micro/micro_test.go @@ -35,7 +35,9 @@ func startup(args []string) (tcell.SimulationScreen, error) { return nil, err } - config.InitRuntimeFiles(true) + config.InitRuntimeFiles() + config.InitPlugins() + err = config.ReadSettings() if err != nil { return nil, err diff --git a/internal/action/command.go b/internal/action/command.go index 0c537df18..a7aa7ea65 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -339,15 +339,19 @@ func ReloadConfig() { reloadRuntime(false) } -func reloadRuntime(reloadAll bool) { - if reloadAll { +func reloadRuntime(reloadPlugins bool) { + if reloadPlugins { err := config.RunPluginFn("deinit") if err != nil { screen.TermMessage(err) } } - config.InitRuntimeFiles(reloadAll) + config.InitRuntimeFiles() + + if reloadPlugins { + config.InitPlugins() + } err := config.ReadSettings() if err != nil { @@ -358,7 +362,7 @@ func reloadRuntime(reloadAll bool) { screen.TermMessage(err) } - if reloadAll { + if reloadPlugins { err = config.LoadAllPlugins() if err != nil { screen.TermMessage(err) @@ -368,7 +372,7 @@ func reloadRuntime(reloadAll bool) { InitBindings() InitCommands() - if reloadAll { + if reloadPlugins { err = config.RunPluginFn("preinit") if err != nil { screen.TermMessage(err) diff --git a/internal/buffer/settings.go b/internal/buffer/settings.go index 1bc2ba0b1..52cbafdb6 100644 --- a/internal/buffer/settings.go +++ b/internal/buffer/settings.go @@ -20,7 +20,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error { } else if option == "statusline" { screen.Redraw() } else if option == "filetype" { - config.InitRuntimeFiles(false) + config.InitRuntimeFiles() err := config.ReadSettings() if err != nil { screen.TermMessage(err) diff --git a/internal/config/rtfiles.go b/internal/config/rtfiles.go index fed6e5069..b43016ce6 100644 --- a/internal/config/rtfiles.go +++ b/internal/config/rtfiles.go @@ -40,15 +40,12 @@ var allFiles [][]RuntimeFile var realFiles [][]RuntimeFile func init() { - initRuntimeVars(true) + initRuntimeVars() } -func initRuntimeVars(reloadAll bool) { +func initRuntimeVars() { allFiles = make([][]RuntimeFile, NumTypes) realFiles = make([][]RuntimeFile, NumTypes) - if reloadAll { - Plugins = Plugins[:0] - } } // NewRTFiletype creates a new RTFiletype @@ -174,47 +171,91 @@ func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile { } // InitRuntimeFiles initializes all assets file and the config directory -func InitRuntimeFiles(reloadAll bool) { +func InitRuntimeFiles() { add := func(fileType RTFiletype, dir, pattern string) { AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern) AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern) } - initRuntimeVars(reloadAll) + initRuntimeVars() add(RTColorscheme, "colorschemes", "*.micro") add(RTSyntax, "syntax", "*.yaml") add(RTSyntaxHeader, "syntax", "*.hdr") add(RTHelp, "help", "*.md") +} + +// InitPlugins initializes the plugins +func InitPlugins() { + Plugins = Plugins[:0] + initlua := filepath.Join(ConfigDir, "init.lua") + + if _, err := os.Stat(initlua); !os.IsNotExist(err) { + p := new(Plugin) + p.Name = "initlua" + p.DirName = "initlua" + p.Srcs = append(p.Srcs, realFile(initlua)) + Plugins = append(Plugins, p) + } - if reloadAll { - initlua := filepath.Join(ConfigDir, "init.lua") - if _, err := os.Stat(initlua); !os.IsNotExist(err) { + // Search ConfigDir for plugin-scripts + plugdir := filepath.Join(ConfigDir, "plug") + files, _ := ioutil.ReadDir(plugdir) + + isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString + + for _, d := range files { + plugpath := filepath.Join(plugdir, d.Name()) + if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() { + srcs, _ := ioutil.ReadDir(plugpath) p := new(Plugin) - p.Name = "initlua" - p.DirName = "initlua" - p.Srcs = append(p.Srcs, realFile(initlua)) + p.Name = d.Name() + p.DirName = d.Name() + for _, f := range srcs { + if strings.HasSuffix(f.Name(), ".lua") { + p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, d.Name(), f.Name()))) + } else if strings.HasSuffix(f.Name(), ".json") { + data, err := ioutil.ReadFile(filepath.Join(plugdir, d.Name(), f.Name())) + if err != nil { + continue + } + p.Info, err = NewPluginInfo(data) + if err != nil { + continue + } + p.Name = p.Info.Name + } + } + + if !isID(p.Name) || len(p.Srcs) <= 0 { + log.Println(p.Name, "is not a plugin") + continue + } Plugins = append(Plugins, p) } + } - // Search ConfigDir for plugin-scripts - plugdir := filepath.Join(ConfigDir, "plug") - files, _ := ioutil.ReadDir(plugdir) - - isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString - + plugdir = filepath.Join("runtime", "plugins") + if files, err := rt.AssetDir(plugdir); err == nil { + outer: for _, d := range files { - plugpath := filepath.Join(plugdir, d.Name()) - if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() { - srcs, _ := ioutil.ReadDir(plugpath) + for _, p := range Plugins { + if p.Name == d { + log.Println(p.Name, "built-in plugin overridden by user-defined one") + continue outer + } + } + + if srcs, err := rt.AssetDir(filepath.Join(plugdir, d)); err == nil { p := new(Plugin) - p.Name = d.Name() - p.DirName = d.Name() + p.Name = d + p.DirName = d + p.Default = true for _, f := range srcs { - if strings.HasSuffix(f.Name(), ".lua") { - p.Srcs = append(p.Srcs, realFile(filepath.Join(plugdir, d.Name(), f.Name()))) - } else if strings.HasSuffix(f.Name(), ".json") { - data, err := ioutil.ReadFile(filepath.Join(plugdir, d.Name(), f.Name())) + if strings.HasSuffix(f, ".lua") { + p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f))) + } else if strings.HasSuffix(f, ".json") { + data, err := rt.Asset(filepath.Join(plugdir, d, f)) if err != nil { continue } @@ -225,7 +266,6 @@ func InitRuntimeFiles(reloadAll bool) { p.Name = p.Info.Name } } - if !isID(p.Name) || len(p.Srcs) <= 0 { log.Println(p.Name, "is not a plugin") continue @@ -233,46 +273,6 @@ func InitRuntimeFiles(reloadAll bool) { Plugins = append(Plugins, p) } } - - plugdir = filepath.Join("runtime", "plugins") - if files, err := rt.AssetDir(plugdir); err == nil { - outer: - for _, d := range files { - for _, p := range Plugins { - if p.Name == d { - log.Println(p.Name, "built-in plugin overridden by user-defined one") - continue outer - } - } - - if srcs, err := rt.AssetDir(filepath.Join(plugdir, d)); err == nil { - p := new(Plugin) - p.Name = d - p.DirName = d - p.Default = true - for _, f := range srcs { - if strings.HasSuffix(f, ".lua") { - p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f))) - } else if strings.HasSuffix(f, ".json") { - data, err := rt.Asset(filepath.Join(plugdir, d, f)) - if err != nil { - continue - } - p.Info, err = NewPluginInfo(data) - if err != nil { - continue - } - p.Name = p.Info.Name - } - } - if !isID(p.Name) || len(p.Srcs) <= 0 { - log.Println(p.Name, "is not a plugin") - continue - } - Plugins = append(Plugins, p) - } - } - } } } diff --git a/internal/config/rtfiles_test.go b/internal/config/rtfiles_test.go index 8b3f23d2a..694e4686e 100644 --- a/internal/config/rtfiles_test.go +++ b/internal/config/rtfiles_test.go @@ -7,7 +7,8 @@ import ( ) func init() { - InitRuntimeFiles(true) + InitRuntimeFiles() + InitPlugins() } func TestAddFile(t *testing.T) { From d906e3982a52d3b442c91d9d96ad27779790263b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:14:36 +0100 Subject: [PATCH 5/5] rtfiles: Remove the unnecessary init function With this modification the InitRuntimeFiles() and InitPlugins() (if needed) must be called first, otherwise uninitialized runtime file variables are most likely. --- internal/buffer/buffer_test.go | 2 ++ internal/config/rtfiles.go | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/buffer/buffer_test.go b/internal/buffer/buffer_test.go index 305d16274..167144264 100644 --- a/internal/buffer/buffer_test.go +++ b/internal/buffer/buffer_test.go @@ -20,6 +20,8 @@ type operation struct { func init() { ulua.L = lua.NewState() + config.InitRuntimeFiles() + config.InitPlugins() config.InitGlobalSettings() config.GlobalSettings["backup"] = false config.GlobalSettings["fastdirty"] = true diff --git a/internal/config/rtfiles.go b/internal/config/rtfiles.go index b43016ce6..53820c5f7 100644 --- a/internal/config/rtfiles.go +++ b/internal/config/rtfiles.go @@ -39,10 +39,6 @@ type RuntimeFile interface { var allFiles [][]RuntimeFile var realFiles [][]RuntimeFile -func init() { - initRuntimeVars() -} - func initRuntimeVars() { allFiles = make([][]RuntimeFile, NumTypes) realFiles = make([][]RuntimeFile, NumTypes)