Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( ConfigFileName = "config" ApplicationFolder = "applications" DatabaseFolder = "databases" DomainFolder = "domains" FunctionFolder = "functions" LibraryFolder = "libraries" MessagingFolder = "messaging" ServiceFolder = "services" SmartOpsFolder = "smartops" StorageFolder = "storages" WebsiteFolder = "websites" )
Variables ¶
This section is empty.
Functions ¶
func StringToTime ¶
StringToTime Converts _time a unit in form 1h10m43s to a uint64 representing nanoseconds
Example ¶
package main import ( "fmt" "log" "github.com/taubyte/tau/pkg/schema/common" ) func main() { unit, err := common.StringToTime("3h") if err != nil { log.Fatal(err) } fmt.Println(unit) unit, err = common.StringToTime("3h10m") if err != nil { log.Fatal(err) } fmt.Println(unit) unit, err = common.StringToTime("10m") if err != nil { log.Fatal(err) } fmt.Println(unit) unit, err = common.StringToTime("5000ns") if err != nil { log.Fatal(err) } fmt.Println(unit) unit, err = common.StringToTime("") if err != nil { log.Fatal(err) } fmt.Println(unit) }
Output: 10800000000000 11400000000000 600000000000 5000 0
func StringToUnits ¶
StringToUnits converts size in a unit in form 1.3KB OR 6.3GB to bytes
Example ¶
package main import ( "fmt" "log" "github.com/taubyte/tau/pkg/schema/common" ) func main() { size, err := common.StringToUnits("64MB") if err != nil { log.Fatal(err) } fmt.Println(size) size, err = common.StringToUnits("64MB10KB") if err != nil { log.Fatal(err) } fmt.Println(size) }
Output: 64000000 64010000
func TimeToString ¶
func TimeToString[T constraints.Integer | time.Duration](_time T) string
TimeToString Converts _time a unit64 representing nanoseconds to a unit in form 1h10m43s
Example ¶
package main import ( "fmt" "time" "github.com/taubyte/tau/pkg/schema/common" ) func main() { unit := common.TimeToString(3 * time.Hour) fmt.Println(unit) unit = common.TimeToString(3*time.Hour + 10*time.Minute) fmt.Println(unit) unit = common.TimeToString(10 * time.Minute) fmt.Println(unit) unit = common.TimeToString(15*time.Millisecond + 10*time.Nanosecond) fmt.Println(unit) unit = common.TimeToString(10 * time.Microsecond) fmt.Println(unit) }
Output: 3h 3h10m 10m 15.00001ms 10µs
func UnitsToString ¶
func UnitsToString[T constraints.Integer](size T) string
UnitsToString converts size in bytes to a unit in form 1.3KB OR 6.3GB
Example ¶
package main import ( "fmt" "github.com/alecthomas/units" "github.com/taubyte/tau/pkg/schema/common" ) func main() { unit := common.UnitsToString(64 * units.MB) fmt.Println(unit) unit = common.UnitsToString(64*units.MB + 10*units.KB) fmt.Println(unit) }
Output: 64MB 64MB10KB
Types ¶
Click to show internal directories.
Click to hide internal directories.