Skip to content

Commit

Permalink
feat: Mise à jour des packages et ajout d'un go mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Millauriaux committed Oct 9, 2023
1 parent e6d9de6 commit 99735b6
Show file tree
Hide file tree
Showing 36 changed files with 131 additions and 113 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Interface to libxml2, with DOM interface.

[![Build Status](https://travis-ci.org/lestrrat-go/libxml2.svg?branch=master)](https://travis-ci.org/lestrrat-go/libxml2)

[![GoDoc](https://godoc.org/github.com/lestrrat-go/libxml2?status.svg)](https://godoc.org/github.com/lestrrat-go/libxml2)
[![GoDoc](https://godoc.org/github.com/icysoft/libxml2?status.svg)](https://godoc.org/github.com/icysoft/libxml2)

# Index

Expand All @@ -13,7 +13,7 @@ Interface to libxml2, with DOM interface.

## Why?

I needed to write [go-xmlsec](https://github.com/lestrrat-go/xmlsec). This means we need to build trees using libxml2, and then muck with it in xmlsec: Two separate packages in Go means we cannot (safely) pass around `C.xmlFooPtr` objects (also, you pay a penalty for pointer types). This package carefully avoid references to `C.xmlFooPtr` types and uses uintptr to pass data around, so other libraries that needs to interact with libxml2 can safely interact with it.
I needed to write [go-xmlsec](https://github.com/icysoft/libxml2/xmlsec). This means we need to build trees using libxml2, and then muck with it in xmlsec: Two separate packages in Go means we cannot (safely) pass around `C.xmlFooPtr` objects (also, you pay a penalty for pointer types). This package carefully avoid references to `C.xmlFooPtr` types and uses uintptr to pass data around, so other libraries that needs to interact with libxml2 can safely interact with it.

## Status

Expand Down Expand Up @@ -72,10 +72,10 @@ import (
"log"
"net/http"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/parser"
"github.com/lestrrat-go/libxml2/types"
"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/parser"
"github.com/icysoft/libxml2/types"
"github.com/icysoft/libxml2/xpath"
)

func ExampleXML() {
Expand Down Expand Up @@ -153,8 +153,8 @@ import (
"os"
"path/filepath"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/xsd"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/xsd"
)

func ExampleXSD() {
Expand Down Expand Up @@ -212,7 +212,7 @@ BenchmarkXmlpathXmlpath-4 500000 11737 ns/op 721 B/op
BenchmarkLibxml2Xmlpath-4 1000000 7627 ns/op 368 B/op 15 allocs/op
BenchmarkEncodingXMLDOM-4 2000000 4079 ns/op 4560 B/op 9 allocs/op
BenchmarkLibxml2DOM-4 1000000 11454 ns/op 264 B/op 7 allocs/op
ok github.com/lestrrat-go/libxml2 37.597s
ok github.com/icysoft/libxml2 37.597s
```

## FAQ
Expand Down Expand Up @@ -280,11 +280,11 @@ See the first FAQ entry.

### I can't build this library statically

See prior discussion: https://github.com/lestrrat-go/libxml2/issues/62
See prior discussion: https://github.com/icysoft/libxml2/issues/62

## See Also

* https://github.com/lestrrat-go/xmlsec
* https://github.com/icysoft/libxml2/xmlsec

## Credits

Expand Down
6 changes: 2 additions & 4 deletions clib/clib.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
Package clib holds all of the dirty C interaction for go-libxml2.
Although this package is visible to the outside world, the API in this
Expand All @@ -16,7 +15,6 @@ Please DO NOT rely on this API and expect that it will keep backcompat.
When the need arises, it WILL be changed, and if you are not ready
for it, your code WILL break in horrible horrible ways. You have been
warned.
*/
package clib

Expand Down Expand Up @@ -343,8 +341,8 @@ import (
"unicode/utf8"
"unsafe"

"github.com/lestrrat-go/libxml2/internal/debug"
"github.com/lestrrat-go/libxml2/internal/option"
"github.com/icysoft/libxml2/internal/debug"
"github.com/icysoft/libxml2/internal/option"
"github.com/pkg/errors"
)

Expand Down
4 changes: 2 additions & 2 deletions dom/c14n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dom_test
import (
"testing"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/dom"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/dom"
"github.com/stretchr/testify/assert"
)

Expand Down
6 changes: 3 additions & 3 deletions dom/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dom_test
import (
"testing"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/dom"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/dom"
"github.com/icysoft/libxml2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion dom/dom.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dom
import (
"sync"

"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2/xpath"
)

var docPool sync.Pool
Expand Down
2 changes: 1 addition & 1 deletion dom/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dom
import (
"errors"

"github.com/lestrrat-go/libxml2/clib"
"github.com/icysoft/libxml2/clib"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions dom/node.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
"github.com/icysoft/libxml2/xpath"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion dom/node_attr.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/icysoft/libxml2/clib"
)

// Free releases the underlying C struct
Expand Down
4 changes: 2 additions & 2 deletions dom/node_document.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
"github.com/pkg/errors"
)

Expand Down
4 changes: 2 additions & 2 deletions dom/node_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"errors"
"strings"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
)

// SetNamespace sets up a new namespace on the given node.
Expand Down
3 changes: 1 addition & 2 deletions dom/node_namespace.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/icysoft/libxml2/clib"
)

// URI returns the namespace URL
Expand All @@ -19,4 +19,3 @@ func (n *Namespace) Free() {
clib.XMLNamespaceFree(n)
n.ptr = 0
}

4 changes: 2 additions & 2 deletions dom/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion dom/node_text.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/icysoft/libxml2/clib"
)

func (n *CDataSection) Literal() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions dom/node_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package dom
import (
"fmt"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
)

func wrapNamespaceNode(ptr uintptr) *Namespace {
Expand Down
4 changes: 2 additions & 2 deletions dom/serialize.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dom

import (
"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/types"
)

// Serialize produces serialization of the document, canonicalized.
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/icysoft/libxml2

go 1.20

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
gopkg.in/xmlpath.v1 v1.0.0-20140413065638-a146725ea6e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/xmlpath.v1 v1.0.0-20140413065638-a146725ea6e7 h1:zibSPXbkfB1Dwl76rJgLa68xcdHu42qmFTe6vAnU4wA=
gopkg.in/xmlpath.v1 v1.0.0-20140413065638-a146725ea6e7/go.mod h1:wo0SW5T6XqIKCCAge330Cd5sm+7VI6v85OrQHIk50KM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 4 additions & 4 deletions html.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"bytes"
"io"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/dom"
"github.com/lestrrat-go/libxml2/parser"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/dom"
"github.com/icysoft/libxml2/parser"
"github.com/icysoft/libxml2/types"
"github.com/pkg/errors"
)

Expand Down
4 changes: 2 additions & 2 deletions html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package libxml2_test
import (
"testing"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/xpath"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/genwrapnode/genwrapnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func _main() error {
buf.WriteString("\n\n// Auto-generated by internal/cmd/genwrapnode/genwrapnode.go. DO NOT EDIT!")
buf.WriteString("\n\nimport (")
buf.WriteString("\n\"fmt\"\n")
for _, lib := range []string{"github.com/lestrrat-go/libxml2/clib", "github.com/lestrrat-go/libxml2/types"} {
for _, lib := range []string{"github.com/icysoft/libxml2/clib", "github.com/icysoft/libxml2/types"} {
fmt.Fprintf(&buf, "\n%s", strconv.Quote(lib))
}
buf.WriteString("\n)")
Expand Down
10 changes: 5 additions & 5 deletions libxml2_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"path/filepath"
"testing"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/dom"
"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/dom"
"github.com/icysoft/libxml2/xpath"
"github.com/stretchr/testify/assert"
"gopkg.in/xmlpath.v1"
)
Expand Down Expand Up @@ -108,7 +108,7 @@ func BenchmarkLibxml2Xmlpath(b *testing.B) {
}

type Foo struct {
XMLName xml.Name `xml:"https://github.com/lestrrat-go/libxml2/foo foo:foo"`
XMLName xml.Name `xml:"https://github.com/icysoft/libxml2/foo foo:foo"`
Field1 string
Field2 string `xml:",attr"`
}
Expand All @@ -128,7 +128,7 @@ func BenchmarkEncodingXMLDOM(b *testing.B) {

func BenchmarkLibxml2DOM(b *testing.B) {
var buf bytes.Buffer
const nsuri = `https://github.com/lestrrat-go/libxml2/foo`
const nsuri = `https://github.com/icysoft/libxml2/foo`
f := Foo{
Field1: "Hello, World!",
Field2: "Hello, Attribute!",
Expand Down
8 changes: 4 additions & 4 deletions libxml2_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"log"
"net/http"

"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/parser"
"github.com/lestrrat-go/libxml2/types"
"github.com/lestrrat-go/libxml2/xpath"
"github.com/icysoft/libxml2"
"github.com/icysoft/libxml2/parser"
"github.com/icysoft/libxml2/types"
"github.com/icysoft/libxml2/xpath"
)

func ExampleXML() {
Expand Down
4 changes: 2 additions & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package libxml2
import (
"io"

"github.com/lestrrat-go/libxml2/parser"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/parser"
"github.com/icysoft/libxml2/types"
)

// Parse parses the given buffer and returns a Document.
Expand Down
6 changes: 3 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"bytes"
"io"

"github.com/lestrrat-go/libxml2/clib"
"github.com/lestrrat-go/libxml2/dom"
"github.com/lestrrat-go/libxml2/types"
"github.com/icysoft/libxml2/clib"
"github.com/icysoft/libxml2/dom"
"github.com/icysoft/libxml2/types"
"github.com/pkg/errors"
)

Expand Down
Loading

0 comments on commit 99735b6

Please sign in to comment.