Answer architecture round 9: each data package exports Modules, a locale's importing its country's geo package as a bench chose, and a namespace mounts a tree through an fs.FS wrapper, so internal/datafiles walks file-system folders alone
This commit is contained in:
+13
-3
@@ -1,9 +1,19 @@
|
||||
// Package enus is fejkdata's en_US locale module, whose categories are en_US.*. Its address reads geous's places.
|
||||
// Package enus is fejkdata's en_US locale module, whose categories are en_US.*; its address reads
|
||||
// geo.US, which package geous holds.
|
||||
package enus
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
|
||||
// FS holds the module's categories and its manifest; pass it to fejkdata.WithDataFS.
|
||||
geous "github.com/larvit/fejkdata/data/geo/US"
|
||||
)
|
||||
|
||||
// FS holds the locale alone, its categories and its manifest; pass Modules unless your own
|
||||
// data stands in for geo.US.
|
||||
//
|
||||
//go:embed *.json *.tsv .fejkdata.json
|
||||
var FS embed.FS
|
||||
|
||||
// Modules returns FS and every module it reads, to pass to fejkdata.WithDataFS.
|
||||
func Modules() []fs.FS { return append([]fs.FS{FS}, geous.Modules()...) }
|
||||
|
||||
+8
-2
@@ -1,9 +1,15 @@
|
||||
// Package geose is fejkdata's Swedish places module, whose categories are geo.SE.*.
|
||||
package geose
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// FS holds the module's categories and its manifest; pass it to fejkdata.WithDataFS.
|
||||
// FS holds the module's categories and its manifest.
|
||||
//
|
||||
//go:embed *.json *.tsv .fejkdata.json
|
||||
var FS embed.FS
|
||||
|
||||
// Modules returns FS, which reads no other module, to pass to fejkdata.WithDataFS.
|
||||
func Modules() []fs.FS { return []fs.FS{FS} }
|
||||
|
||||
+8
-2
@@ -1,9 +1,15 @@
|
||||
// Package geous is fejkdata's US places module, whose categories are geo.US.*.
|
||||
package geous
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// FS holds the module's categories and its manifest; pass it to fejkdata.WithDataFS.
|
||||
// FS holds the module's categories and its manifest.
|
||||
//
|
||||
//go:embed *.json *.tsv .fejkdata.json
|
||||
var FS embed.FS
|
||||
|
||||
// Modules returns FS, which reads no other module, to pass to fejkdata.WithDataFS.
|
||||
func Modules() []fs.FS { return []fs.FS{FS} }
|
||||
|
||||
+8
-2
@@ -1,9 +1,15 @@
|
||||
// Package misc is fejkdata's locale-neutral module, whose categories are misc.*.
|
||||
package misc
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// FS holds the module's categories and its manifest; pass it to fejkdata.WithDataFS.
|
||||
// FS holds the module's categories and its manifest.
|
||||
//
|
||||
//go:embed *.json *.tsv .fejkdata.json
|
||||
var FS embed.FS
|
||||
|
||||
// Modules returns FS, which reads no other module, to pass to fejkdata.WithDataFS.
|
||||
func Modules() []fs.FS { return []fs.FS{FS} }
|
||||
|
||||
+13
-3
@@ -1,9 +1,19 @@
|
||||
// Package svse is fejkdata's sv_SE locale module, whose categories are sv_SE.*. Its address reads geose's places.
|
||||
// Package svse is fejkdata's sv_SE locale module, whose categories are sv_SE.*; its address reads
|
||||
// geo.SE, which package geose holds.
|
||||
package svse
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
|
||||
// FS holds the module's categories and its manifest; pass it to fejkdata.WithDataFS.
|
||||
geose "github.com/larvit/fejkdata/data/geo/SE"
|
||||
)
|
||||
|
||||
// FS holds the locale alone, its categories and its manifest; pass Modules unless your own
|
||||
// data stands in for geo.SE.
|
||||
//
|
||||
//go:embed *.json *.tsv .fejkdata.json
|
||||
var FS embed.FS
|
||||
|
||||
// Modules returns FS and every module it reads, to pass to fejkdata.WithDataFS.
|
||||
func Modules() []fs.FS { return append([]fs.FS{FS}, geose.Modules()...) }
|
||||
|
||||
Reference in New Issue
Block a user