Working on Structure Reflection
This commit is contained in:
35
example/main.go
Normal file
35
example/main.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.bullercodeworks.com/brian/boltease"
|
||||
)
|
||||
|
||||
type ExampleType struct {
|
||||
Name string `boltease:"name"`
|
||||
Age int `boltease:"age"`
|
||||
}
|
||||
|
||||
type ExampleSubType struct {
|
||||
SubName string `boltease:"subname"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
db, err := boltease.Create("example.db", 0600, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error Opening File: %s\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
err = db.SaveStruct(
|
||||
[]string{"examples", "example1"},
|
||||
ExampleType{
|
||||
Name: "Example 1",
|
||||
Age: 5,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("Error saving struct: %s\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user