mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-09-05 16:37:20 -04:00
- Guard aginst non-existing syn highlighter file
- Create mod file in `examples` dir
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user