initial import

This commit is contained in:
2022-02-21 17:37:47 -08:00
commit 02a6356158
4 changed files with 83 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
ark
blobs
*.db

View 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
View File

@@ -0,0 +1,7 @@
package kg
type Cell struct {
ID string
Contents []byte
Type string
}

5
src/types/kg/node.go Normal file
View File

@@ -0,0 +1,5 @@
package kg
type Node struct {
ID string
}