A pure Go implementation for working with GS1 Data in various syntax variations as well as with GS1 Application Identifiers (AI).
Highlights:
- ✅ Pure Go implementation, zero external dependencies
- ✅ Parser support for the following syntax types:
- GS1 element string syntax (e.g.
(01)09526064055028(17)250521(10)ABC123(21)456DEF
) - Barcode message format (e.g.
^01095260640550281725052110ABC123^21456DEF
) - Barcode message scan data (e.g.
]d201095260640550281725052110ABC123{GS}21456DEF
)
- GS1 element string syntax (e.g.
- ✅ AI Registry with description of all 536 AIs (as of release
2025-01-30
) - ✅ Go Code generator CLI to generate AI description based on the official GS1 Syntax Dictionary
- ✅ Usable examples in
examples/
⛔️ NO STABLE API yet. Not functional complete, see the following roadmap:
- Implement GS1 data parsing support for:
- Digital-Link URI Syntax (e.g.
https://example.com/01/09526064055028
)
- Digital-Link URI Syntax (e.g.
- Implement high-level interface to easily work with GS1 description (Flags, Specification, Attributes)
- Implement validation support by implementing linters to validate that an AI conforms
- to its Specification (e.g
yymmdd
orN6
) - and to its attributes (e.g
req
andex
to define valid and invalid pairings).
- to its Specification (e.g
- Add GitHub workflows:
- Unit Testing with code coverage
- Linting
- Add badges for build status and code coverage
Add it to your project:
go get github.com/adippel/gs1engine-go
Several examples exist in examples/
showcasing the parser:
- read2dcode - Example to parse GS1 messages from 2D barcodes
- cliparser - Example to parse GS1 message from CLI input
Several GS1 syntax formats are supported via the following functions:
- ParseMessage: Automatically detects syntax type based on input and then uses the correct parsers.
- ParseBarcodeMessage: Parses barcode message
format and barcode scan data (e.g.
]d2...
,^...
) - ParseElementString: Parses element string
syntax (e.g
(01)...(17)...
)
All parser support the visual FNC1 substitutes ^
and {GS}
.
🛑 Plain syntax (non-AI form) is not supported.
To start parsing, use the following:
gs1Messages := []string{
"]d201095260640550281725052110ABC123{GS}21456DEF",
"^01095260640550281725052110ABC123^21456DEF",
"(01)09526064055028(17)250521(10)ABC123(21)456DEF",
}
for _, gs1Msg := range gs1Messages {
gs1Data, _ := gs1.ParseMessage(gs1Msg)
fmt.Println("Detected GS1 Syntax Type:", gs1Data.SyntaxType)
fmt.Println("Message:", gs1Data.AsElementString())
}
The GS1 has good reference material to understand their system and approaches:
- To see the whole collection of available documents, see the GS1 reference
- For technical details, see GS1 Barcode Syntax Resource User Guide
- For a broader picture, see GS1 System Architecture
- GS1-maintained syntax engine in C