go-bo4e
Business Objects for Energy (BO4E) Implementation in Go. Highlights are
- includes
json
tags for easy (un)marshalling
- comes with builtin validator logic
- is linted and has decent test coverage
This package (as of September 2021) implements
- BO Energiemenge
- BO Geschaeftspartner
- BO Lastgang
- BO Messlokation
- BO Rechnung
- BO Vertrag
- BO Zaehler
so far.
Installation
go get github.com/hochfrequenz/go-bo4e
Minimal Working Example
package main
import (
"encoding/json"
"fmt"
"github.com/go-playground/validator/v10"
"github.com/hochfrequenz/go-bo4e/bo"
"github.com/hochfrequenz/go-bo4e/com"
"github.com/hochfrequenz/go-bo4e/enum/botyp"
"github.com/hochfrequenz/go-bo4e/enum/landescode"
"github.com/hochfrequenz/go-bo4e/enum/sparte"
)
func main() {
melo := bo.Messlokation{
BusinessObject: bo.BusinessObject{
BoTyp: botyp.Messlokation,
VersionStruktur: "1",
ExterneReferenzen: nil,
},
MesslokationsId: "DE0000011111222223333344444555556",
Sparte: sparte.Strom,
Messadresse: &com.Adresse{
Postleitzahl: "82031",
Ort: "Grünwald",
Strasse: "Nördliche Münchner Straße",
Hausnummer: "27A",
Landescode: landescode.DE,
},
}
vali := validator.New()
err := vali.Struct(melo)
if err == nil {
fmt.Println("The MeLo is valid.")
}
meloBytes, err := json.Marshal(melo)
meloJson := string(meloBytes)
fmt.Print(meloJson)
}
Use this in the Go Playground.
Other Noteworthy BO4E Implementations
Contributing
Contributions are welcome. Feel free to open a Pull Request against the main branch of this repository. Please provide
unit tests if you contribute logic beyond bare bare business object definitions. We do track our modification proposals
to the official BO4E standard in a separate
repository: BO4E-modification-proposals.
Hochfrequenz
Hochfrequenz Unternehmensberatung GmbH is a Grünwald (near Munich) based consulting
company with offices in Berlin and Bremen. We're not only the main contributor to open source BO4E software but,
according to Kununu ratings, also among the most
attractive employers within the German energy market. Applications of talented developers are welcome at any time!
Please consider visiting
our career page (
German only).