-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,629 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# A | ||
-- | ||
import "gotro/A" | ||
|
||
|
||
## Usage | ||
|
||
#### func FloatExist | ||
|
||
```go | ||
func FloatExist(arr []float64, val float64) bool | ||
``` | ||
check if float exists on array | ||
|
||
#### func IntAppendIfNotExists | ||
|
||
```go | ||
func IntAppendIfNotExists(arr []int64, str int64) []int64 | ||
``` | ||
Append if not exists | ||
|
||
#### func IntContains | ||
|
||
```go | ||
func IntContains(arr []int64, str int64) bool | ||
``` | ||
Append int64 to array of string if not exists | ||
|
||
#### func IntJoin | ||
|
||
```go | ||
func IntJoin(arr []int64, sep string) string | ||
``` | ||
combine int64s in the array of int64 with the chosen string separator | ||
|
||
m1:= []int64{123,456} | ||
A.IntJoin(m1,`|`) // 123|456 | ||
|
||
#### func IntsAppendIfNotExists | ||
|
||
```go | ||
func IntsAppendIfNotExists(arr []int64, ints []int64) []int64 | ||
``` | ||
Append slices if not exists | ||
|
||
#### func ParseEmail | ||
|
||
```go | ||
func ParseEmail(str_emails, each_name string) []string | ||
``` | ||
split, add alias, and concat emails with name | ||
|
||
#### func StrAppendIfNotExists | ||
|
||
```go | ||
func StrAppendIfNotExists(arr []string, str string) []string | ||
``` | ||
Append if not exists | ||
|
||
#### func StrContains | ||
|
||
```go | ||
func StrContains(arr []string, str string) bool | ||
``` | ||
Append string to array of string if not exists | ||
|
||
#### func StrJoin | ||
|
||
```go | ||
func StrJoin(arr []string, sep string) string | ||
``` | ||
combine strings in the array of string with the chosen string separator | ||
|
||
m1:= []string{`satu`,`dua`} | ||
A.StrJoin(m1,`-`) // satu-dua | ||
|
||
#### func StrToInt | ||
|
||
```go | ||
func StrToInt(arr []string) []int64 | ||
``` | ||
|
||
Convert array of string to array of int64 | ||
func main() { | ||
|
||
m:= []string{`1`,`2`} | ||
L.Print(A.StrToInt(m))//output [1 2] | ||
|
||
} | ||
|
||
convert string list to integer list | ||
|
||
#### func StrsAppendIfNotExists | ||
|
||
```go | ||
func StrsAppendIfNotExists(arr []string, strs []string) []string | ||
``` | ||
Append slices if not exists | ||
|
||
#### func ToJson | ||
|
||
```go | ||
func ToJson(arr []interface{}) string | ||
``` | ||
convert map array of string to JSON string type | ||
|
||
m:= []interface{}{123,`abc`} | ||
L.Print(A.ToJson(m)) // [123,"abc"] | ||
|
||
#### func UIntJoin | ||
|
||
```go | ||
func UIntJoin(arr []uint64, sep string) string | ||
``` | ||
combine uint64s in the array of int64 with the chosen string separator | ||
|
||
m1:= []uint64{123,456} | ||
A.UIntJoin(m1,`-`) // 123-456 | ||
|
||
#### type MSX | ||
|
||
```go | ||
type MSX []map[string]interface{} | ||
``` | ||
|
||
array (slice) of map with string key and any value | ||
|
||
v := A.MSX{} | ||
v = append(v, map[string]{ | ||
`foo`: 123, | ||
`bar`: `yay`, | ||
}) | ||
|
||
#### type X | ||
|
||
```go | ||
type X []interface{} | ||
``` | ||
|
||
array (slice) of anything | ||
|
||
v := A.X{} | ||
v = append(v, any_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# B | ||
-- | ||
import "gotro/B" | ||
|
||
|
||
## Usage | ||
|
||
#### func ToS | ||
|
||
```go | ||
func ToS(b bool) string | ||
``` | ||
converts boolean type to string type, writing "true" or "false" | ||
|
||
B.ToS(2 > 1) // "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# C | ||
-- | ||
import "gotro/C" | ||
|
||
|
||
## Usage | ||
|
||
#### func IsDigit | ||
|
||
```go | ||
func IsDigit(ch byte) bool | ||
``` | ||
check whether the character is a digit or not | ||
|
||
C.IsDigit('9') // true | ||
|
||
#### func IsIdent | ||
|
||
```go | ||
func IsIdent(ch byte) bool | ||
``` | ||
check whether the character is a valid identifier suffix alphanumeric | ||
(letter/underscore/numeral) | ||
|
||
C.IsIdent('9')) | ||
|
||
#### func IsIdentStart | ||
|
||
```go | ||
func IsIdentStart(ch byte) bool | ||
``` | ||
check whether the character is a valid identifier prefix (letter/underscore) | ||
|
||
C.IsIdentStart('-') // false | ||
C.IsIdentStart('_') // true | ||
|
||
#### func IsValidFilename | ||
|
||
```go | ||
func IsValidFilename(ch byte) bool | ||
``` | ||
check whether the character is a safe file-name characters | ||
(alphanumeric/comma/full-stop/dash) | ||
|
||
C.IsValidFilename(' ') // output bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# F | ||
-- | ||
import "gotro/F" | ||
|
||
|
||
## Usage | ||
|
||
#### func If | ||
|
||
```go | ||
func If(b bool, yes float64) float64 | ||
``` | ||
simplified ternary operator (bool ? val : 0), returns second argument, if the | ||
condition (first arg) is true, returns 0 if not | ||
|
||
F.If(true,3.12) // 3.12 | ||
F.If(false,3) // 0 | ||
|
||
#### func IfElse | ||
|
||
```go | ||
func IfElse(b bool, yes, no float64) float64 | ||
``` | ||
ternary operator (bool ? val1 : val2), returns second argument if the condition | ||
(first arg) is true, third argument if not | ||
|
||
F.IfElse(true,3.12,3.45)) // 3.12 | ||
|
||
#### func ToDateStr | ||
|
||
```go | ||
func ToDateStr(num float64) string | ||
``` | ||
convert float64 unix to `YYYY-MM-DD` | ||
|
||
#### func ToIsoDateStr | ||
|
||
```go | ||
func ToIsoDateStr(num float64) string | ||
``` | ||
convert to ISO-8601 string | ||
|
||
F.ToIsoDateStr(0) // `1970-01-01T00:00:00` | ||
|
||
#### func ToS | ||
|
||
```go | ||
func ToS(num float64) string | ||
``` | ||
convert float64 to string | ||
|
||
F.ToS(3.1284)) // `3.1284` | ||
|
||
#### func ToStr | ||
|
||
```go | ||
func ToStr(num float64) string | ||
``` | ||
convert float64 to string with 2 digits behind the decimal point | ||
|
||
F.ToStr(3.1284)) // `3.13` |
Oops, something went wrong.