https://github.com/lestrrat-go/helium
(Work In Progress) An exercise rewriting libxml2 in Go
https://github.com/lestrrat-go/helium
Last synced: about 2 months ago
JSON representation
(Work In Progress) An exercise rewriting libxml2 in Go
- Host: GitHub
- URL: https://github.com/lestrrat-go/helium
- Owner: lestrrat-go
- License: mit
- Created: 2015-12-17T14:15:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T14:07:56.000Z (over 4 years ago)
- Last Synced: 2024-06-20T11:10:31.887Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 456 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# helium
[](https://travis-ci.org/lestrrat-go/helium)
[](https://godoc.org/github.com/lestrrat-go/helium)# What on earth?
This is an exercise in rewriting libxml2 in its entirety in Go. Why? I've run into
performance blockers while using cgo and libxml2, and I couldn't squeeze out that last
drop of performance out of it. Also, there was also [this](https://github.com/golang/go/issues/13400), which I thought was a shame to not be able to handle XML using pure Go.So I started -- and I still have a long way to go.
# SYNOPSIS
Parsing XML into a DOM model, then dumping it:
```go
import "github.com/lestrrat-go/helium"func main() {
doc, err := helium.Parse(`.... xml string ....`)
if err != nil {
panic("failed to parse XML: " + err.Error())
}// Dump this XML
doc.XML(os.Stdout)
}
```Using command line `helium-lint` (very under developed right now):
```
helium-lint xmlfile ...
``````
cat xmlfile | helium-lint
```# Get it
```
go get github.com/lestrrat-go/helium
```# Test it
```
go test
```In order to get helpful debug messages:
```
go test -tags debug
```# Current status
* Good news: parse/dump basic XML with some DTDs are now working.
* Bad news: I have run out of tuits. I intend to work on this from time to time, but I *REALLY* need people's help. See "Contributing" below.
* While XML declaration is parsed, encoding is ignored, and assumed to be UTF-8# Contributing
I won't have much time to discuss: let the code talk: Give me PRs that are self-explanatory! :)
The goal for the moment is to "port" libxml2. That means that where possible, we should just steal their code, even if things aren't too go-ish. We'll polish after we have a compatible implementation. So don't debate for optimal go-ness unless it's a really low hanging fruit.
Help in forms for PRs is better, but if you insiste, Amazon gift cards to lestrrat at gmail is appreciated ;)
To get started, see notes on test structure below. Grab some files from libxml2, and see
if things work. If it doesn't work, fix it! :)# Test structure
As of this writing, `dump_test.go` and `sax_test.go` both look for the presence of XML
files under test directory, and parse+dumps appropriate output after seeing that there's
a corresponding `*.dump` or `*.sax2` files.For SAX tests, do note that letter casing and such are different from that of libxml2.
# What's with the naming?
I thought it sounded cool. Not set in stone, so we may change it later.