initial import
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
ark
|
||||
blobs
|
||||
*.db
|
||||
68
src/types/core/metadata.go
Normal file
68
src/types/core/metadata.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ExoBasePath is the base path to the exocortex data stores.
|
||||
var ExoBasePath = filepath.Join(os.Getenv("HOME"), "exo")
|
||||
|
||||
const (
|
||||
// ValueTypeUnspecified is used when the value type hasn't been explicitly
|
||||
// set. It should be interpreted as a string in the absence of further
|
||||
// information.
|
||||
ValueTypeUnspecified = "UNSPECIFIED"
|
||||
|
||||
// ValueTypeString is used when the value type should be explicitly
|
||||
// interpreted as a string.
|
||||
ValueTypeString = "String"
|
||||
)
|
||||
|
||||
// For the sake of storage, values are stored as strings; associate type
|
||||
// information so that interested consumers can handle correctly.
|
||||
type Value struct {
|
||||
Contents string
|
||||
Type string
|
||||
}
|
||||
|
||||
// Val creates a new Value with an unspecified type.
|
||||
func Val(contents string) Value {
|
||||
return Value{
|
||||
Contents: contents,
|
||||
Type: ValueTypeUnspecified,
|
||||
}
|
||||
}
|
||||
|
||||
// Vals creates a new Value with a string type.
|
||||
func Vals(contents string) Value {
|
||||
return Value{
|
||||
Contents: contents,
|
||||
Type: ValueTypeString,
|
||||
}
|
||||
}
|
||||
|
||||
// Metadata holds additional information that isn't explicitly part of a data
|
||||
// definition.
|
||||
type Metadata map[string]Value
|
||||
|
||||
// UUID returns a new UUID or panics.
|
||||
func UUID() string {
|
||||
return uuid.NewString()
|
||||
}
|
||||
|
||||
// ErrNoID is returned when a lookup is done on a struct that has no
|
||||
// identifier attached..
|
||||
var ErrNoID = errors.New("missing UUID identifier")
|
||||
|
||||
func MapFromList(list []string) map[string]bool {
|
||||
m := map[string]bool{}
|
||||
for _, s := range list {
|
||||
m[s] = true
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
7
src/types/kg/cell.go
Normal file
7
src/types/kg/cell.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package kg
|
||||
|
||||
type Cell struct {
|
||||
ID string
|
||||
Contents []byte
|
||||
Type string
|
||||
}
|
||||
5
src/types/kg/node.go
Normal file
5
src/types/kg/node.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package kg
|
||||
|
||||
type Node struct {
|
||||
ID string
|
||||
}
|
||||
Reference in New Issue
Block a user