Skip to content

chrnin/libinpibilan

Repository files navigation

libinpibilan: Déchiffrer les bilans INPI en go pur

Usage

Lire un fichier

package main

import (
	"fmt"
	"github.com/chrnin/libinpibilan"
)

func main() {
	source, err := os.Open("path/bilan.xml")
    if err != nil {
        panic(err)
    }
	if bilan, err := libinpibilan.NewBilanWithReader(source); err != nil {
        fmt.Printf("lecture du fichier impossible: %+v\n", err)
    } else {
        fmt.Println(bilan)
    }
}

Lire un tableau de bytes

package main

import (
	"fmt"
	"io/ioutil"
	"github.com/chrnin/libinpibilan"
)

func main() {
	source, err := ioutil.ReadFile("test/test.xml")
	if err != nil {
        panic(err)
    }
	if bilan, err := libinpibilan.NewBilanWithBytes(source); err != nil {
        fmt.Printf("lecture du fichier impossible: %+v\n", err)
    } else {
        fmt.Println(bilan)
    }
}

Convertir les bilans dans une goroutine

package main

import (
	"fmt"
	"io/ioutil"
	"github.com/chrnin/libinpibilan"
)

func main() {
	source, err := ioutil.ReadFile("test/test.xml")
    if err != nil {
        panic(err)
    }
	
	bytesChannel := make(chan []byte)
	bilanChannel := libinpibilan.NewBilanRoutineWithBytesChan(bytesChannel, 1)
	
	bytesChannel <- source
	bilan := <- bilanChannel

	fmt.Println(bilan)
}

About

go module aimed to read INPI bilan XML files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages