- Guard aginst non-existing syn highlighter file

- Create mod file in `examples` dir
This commit is contained in:
Jesse Portnoy
2023-07-16 02:12:12 +01:00
parent 291680feac
commit 5fa7eb841e
4 changed files with 42 additions and 3 deletions
+6 -2
View File
@@ -41,13 +41,17 @@ func main() {
import "fmt"
// A hello world program
func main() {
func helloWorld() {
fmt.Println("Hello world")
}`
// Load the go syntax file
// Make sure that the syntax_files directory is in the current directory
syntaxFile, _ := ioutil.ReadFile("highlight/syntax_files/go.yaml")
syntaxFile, lerr := ioutil.ReadFile("highlight/syntax_files/go.yaml")
if lerr != nil {
fmt.Println(lerr)
return
}
// Parse it into a `*highlight.Def`
syntaxDef, err := highlight.ParseDef(syntaxFile)