forked from TrueCloudLab/frostfs-locode-db
[#7] Add local tool for building database file
Added frostfs-locode-db CLI utility that can generate and view UN/LOCODE database files. Go package git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/locode copied to this repository to eliminate interdependency between frostfs-node and frostfs-locode-db projects. The process of building database files reduced to starting make command. Signed-off-by: George Bartolomey <george@bh4.ru>
This commit is contained in:
parent
7e523f1a28
commit
840b20538b
30 changed files with 2317 additions and 4 deletions
32
pkg/locode/db/location.go
Normal file
32
pkg/locode/db/location.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package locodedb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
locodecolumn "git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode/column"
|
||||
)
|
||||
|
||||
// LocationCode represents a location code for
|
||||
// the storage in the FrostFS location database.
|
||||
type LocationCode locodecolumn.LocationCode
|
||||
|
||||
// LocationCodeFromString parses a string UN/LOCODE location code
|
||||
// and returns a LocationCode.
|
||||
func LocationCodeFromString(s string) (*LocationCode, error) {
|
||||
lc, err := locodecolumn.LocationCodeFromString(s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse location code: %w", err)
|
||||
}
|
||||
|
||||
return LocationFromColumn(lc)
|
||||
}
|
||||
|
||||
// LocationFromColumn converts a UN/LOCODE country code to a LocationCode.
|
||||
func LocationFromColumn(cc *locodecolumn.LocationCode) (*LocationCode, error) {
|
||||
return (*LocationCode)(cc), nil
|
||||
}
|
||||
|
||||
func (l *LocationCode) String() string {
|
||||
syms := (*locodecolumn.LocationCode)(l).Symbols()
|
||||
return string(syms[:])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue