GO-db: Independent Address File Based Database for Go-Lang
Go-Lang is a fairly new language by Google, which translates to the best processing speeds, compared to the other languages
in the market.
However, there is lack of any good File Based Database Management System, which could be reliable enough to meet the vigorous
computing needs, and at the same time be simple to use.
We have made an attempt to bridge this gap, by developing GO-db.
First: Why to use GO-db?
GO-db is a simple to use file based database, which is light, simple and efficient on resources. It has been designed with
simplicity in AIM.
Installation
add "github.com/Harkishen-Singh/GO-db/gobase"
to import block of your file and open the terminal, and type go get -v -t -d && go build -v
Usage
Saving
- Saving data into the file
- To save a data of String Type:
gobase.Save(path string, data *string) bool
- Similarly to save the data of different datatypes:
gobase.Save{datatype_code}(path string, data *{datatype}) bool
Example:
var details = "some data"
var id uint16 = 1234
gobase.Save("Test", &details)
gobase.SaveUint16("Random/Path/Test", &id)
return_param 1: Status i.e., True if successful, else False
- Saving array type data into the file
- To save an array of String Type:
gobase.SaveArr(path string, data *string) bool
- Similarly to save an array of different datatypes:
gobase.SaveArr{datatype_code}(path string, data *{datatype}) bool
Example:
var details = {"Some", "Data"}
var vals = []uint8{1,2,3,4,5}
gobase.SaveArr("TestArray", &details)
gobase.SaveArrUint8("Random/Path/TestArray", &vals)
return_param 1: Status i.e., True if successful, else False
The datatype codes for different datatypes are:
Datatype |
Datatype Code |
Unsigned Integer8 |
Uint8 |
Unsigned Integer16 |
Uint16 |
Unsigned Integer32 |
Uint32 |
Unsigned Integer64 |
Uint64 |
Signed Integer8 |
Int8 |
Signed Integer16 |
Int16 |
Signed Integer32 |
Int32 |
Signed Integer64 |
Int64 |
Integer |
Int |
Float32 |
Float32 |
Float64 |
Float64 |
Retriving
- To retrieve the data:
gobase.Retrive(path string) (string, string, bool)
return_param 1: Available data at the specified path if successful; else ERROR_CODE: DOCUMENT_UNAVAILABLE
or ERROR
return_param 2: DataType of the stored data
return_param 3: Status i.e., True if successful, else False
Example:
gobase.Retrive("Test") //output: some data string true
gobase.Retrive("Random/Path/Test") //output: 1234 _uint8 true
- To Retrieve an array:
gobase.RetriveArr(path string) ([]string, string, bool)
return_param 1: Available data at the specified path if successful; else ERROR_CODE: DOCUMENT_UNAVAILABLE
or ERROR
return_param 2: DataType of the stored data
return_param 3: Status i.e., True if successful, else False
Example:
gobase.RetriveArr("TestArray") //output:[some data] string true
gobase.RetriveArr("Random/Path/TestArray") //output:[1 2 3 4 5] _uint8 true
Get Available Collections at an Address / Path
gobase.CollectionsAvaliable(path string) ([]string, bool)
return_param 1: Available Collections at the specified path
return_param 2: Status i.e., True if successful, else False
Example:
gobase.CollectionsAvaliable("/") // output: [Test.data, TestArray.data, Random]
gobase.CollectionsAvaliable("Random") // output: [Path]
Deleting
It deletes the mentioned file and cleans up all the Empty Directories in the Warehouse Folder
gobase.Delete(path string) bool
return_param 1: Status i.e., True if successful, else False
Example:
gobase.Delete("/") // deletes all collections
gobase.Delete("Random") // deletes Random collection