This file contains hidden or 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
| import ( | |
| "time" | |
| "fmt" | |
| ) | |
| func main() { | |
| timeZone := "Asia/Kolkata" // timezone value | |
| loc, _ := time.LoadLocation(timeZone) | |
| currentTime = time.Now().In(loc) | |
| fmt.Println("currentTime : ", currentTime) |
This file contains hidden or 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
| import "fmt" | |
| func main() { | |
| smallerNo := 5 | |
| largerNo := 25 | |
| result := float32(smallerNo) / float32(largerNo) | |
| fmt.Println("result : ", result) | |
| } | |
This file contains hidden or 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
| import "fmt" | |
| func main() { | |
| // define array of strings | |
| fruits := []string{"Mango", "Grapes", "Kiwi", "Apple", "Grapes"} | |
| fmt.Println("Array before removing duplicates : ", fruits) | |
| // Array after duplicates removal | |
| dulicatesRemovedArray := RemoveDuplicatesFromSlice(fruits) | |
| fmt.Println("Array after removing duplicates : ", dulicatesRemovedArray) |
This file contains hidden or 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
| import "fmt" | |
| func main() { | |
| // shuffle array | |
| array := []string{"India", "US", "Canada", "UK"} | |
| Shuffle(array) | |
| } | |
| func Shuffle(array []string) { | |
| // seed random for changing order of elements |
This file contains hidden or 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
| import "fmt" | |
| func main() { | |
| a := []int{1, 2, 3, 4, 5, 6} // input int array | |
| reverseArray := ReverseSlice(a) | |
| fmt.Println("Reverted array : ", reverseArray) // print output | |
| } | |
| func ReverseSlice(a []int) []int { |
This file contains hidden or 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
| import "fmt" | |
| func main() { | |
| s := []int{10, 20, 30} | |
| sum := sumSlice(s) | |
| fmt.Println("Sum of slice elements : ", sum) | |
| } | |
This file contains hidden or 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
| import ( | |
| "fmt" | |
| "strings" | |
| "strconv" | |
| ) | |
| func main() { | |
| result := ConvertSliceToString([]int{10, 20, 30, 40}) | |
| fmt.Println("Slice converted string : ", result) |
This file contains hidden or 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
| import ( | |
| "fmt" | |
| "strings" | |
| "regexp" | |
| ) | |
| func main() { | |
| snakeCase := ConvertToSnakeCase("ILikeProgrammingINGo123") | |
| fmt.Println("String in snake case : ", snakeCase) |
This file contains hidden or 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
| func getDecodedFireBaseKey() ([]byte, error) { | |
| fireBaseAuthKey := os.Getenv("FIREBASE_AUTH_KEY") | |
| decodedKey, err := base64.StdEncoding.DecodeString(fireBaseAuthKey) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return decodedKey, nil |
This file contains hidden or 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
| decodedKey, err := getDecodedFireBaseKey() | |
| if err != nil { | |
| return err | |
| } | |
| opts := []option.ClientOption{option.WithCredentialsJSON(decodedKey)} | |
| // Initialize firebase app | |
| app, err := firebase.NewApp(context.Background(), nil, opts...) |