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" |
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" | |
type Person struct { | |
Name string | |
Surname string | |
} | |
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 ( | |
"log" | |
"reflect" | |
"os" | |
) | |
// Find an object in a slice comparing a KEY (string) and its VALUE (interface{}) | |
func findByKey(objArr interface{}, key string, value interface{}) interface{} { |
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 ( | |
"bytes" | |
"encoding/json" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"os" | |
"time" |
NewerOlder