This commit is contained in:
sam 2024-09-19 02:12:57 +02:00
commit 9298fc4e4c
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
12 changed files with 599 additions and 0 deletions

View file

@ -0,0 +1,38 @@
package packages
import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
)
type Package struct {
Name string
Dependencies []Dependency
}
type Dependency struct {
Name string
Version string
}
func LookupPackageFile(name string) (io.Reader, error) {
path := filepath.Join("./packages", name+".lua")
f, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("opening package file: %w", err)
}
defer f.Close()
buf := new(bytes.Buffer)
_, err = io.Copy(buf, f)
if err != nil {
return nil, fmt.Errorf("reading package file: %w", err)
}
return buf, nil
}