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
// Package main demonstrates Go iterator patterns using the iter package. | |
// This program showcases both built-in iterators from maps/slices packages | |
// and custom iterator implementation. | |
package main | |
import ( | |
"fmt" // for formatted output | |
"iter" // for iterator types (Go 1.23+) | |
"maps" // for map iterator utilities | |
"slices" // for slice iterator utilities |
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
package main | |
import ( | |
"context" | |
"fmt" | |
"os" | |
"time" | |
) | |
func main() { |
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
package main | |
import ( | |
"fmt" | |
"io" | |
"net/http" | |
) | |
// Result holds the result of a work function execution | |
type Result struct { |
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
package main | |
import "fmt" | |
func fibRecursive(position uint) uint { | |
if position <= 2 { | |
return 1 | |
} | |
return fibRecursive(position-1) + fibRecursive(position-2) | |
} |
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
/* Small screens, laptops (landscape) ----------- */ | |
@media only screen | |
and (min-device-width : 769px) | |
and (max-device-width : 1024px) { | |
/* Styles */ | |
} | |
/* Desktops & large screens (landscape) ----------- */ | |
@media only screen | |
and (min-device-width : 1025px) |
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
package main | |
import "fmt" | |
func main() { | |
intSlice := []int{1, 2, 3} | |
floatSlice := []float64{1.0, 2.0, 3.0} | |
stringSlice := []string{"a", "b", "c"} | |
mapString := map[string]string{ | |
"Name": "Pedro", |
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
package main | |
import "fmt" | |
func main() { | |
minInt := min(3, 2, 1, 4) | |
minFloat := min(4.0, 2.0, 3.0, 1.0) | |
minString := min("ab", "a", "abcd", "abc") |
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
################################################# | |
## EXAMPLE OF USAGE OF ANY IN AN OBJECT/STRUCT ## | |
################################################# | |
package main | |
import "fmt" | |
const ( | |
MALE string = "male" | |
FEMALE string = "female" |
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
/* | |
Retry function using closure | |
*/ | |
package main | |
import ( | |
"errors" | |
"fmt" | |
"time" | |
) |
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
/* | |
How to use context with timeout to cancel a slow operation. | |
The same concept can be used with context.WithDeadline() | |
*/ | |
package main | |
import ( | |
"context" | |
"fmt" | |
"time" |
NewerOlder