File is now capable of printing errors

This commit is contained in:
Sasha Koshka 2022-08-03 13:28:37 -04:00
parent 4d94e5738d
commit 64a8a2445a

View File

@ -1,22 +1,22 @@
package file package file
import "os" import "os"
import "path/filepath" import "log"
var logger = log.New(os.Stderr, "", 0)
// File represents a read only file that can print out formatted errors.
type File struct { type File struct {
path string path string
moduleName string
file *os.File file *os.File
currentLine int currentLine int
lines [][]byte lines [][]byte
} }
// Open opens the file specified by path and returns a new File struct. The // Open opens the file specified by path and returns a new File struct.
// module name is automatically inferred through hte file's parent directory.
func Open (path string) (file *File, err error) { func Open (path string) (file *File, err error) {
file = &File { file = &File {
path: path, path: path,
moduleName: filepath.Dir(path),
lines: [][]byte { []byte { } }, lines: [][]byte { []byte { } },
} }