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
type TemperamentЕype int | |
const ( | |
TypicalSanguinePerson TemperamentЕype = iota // 0 | |
TypicalCholericSubject // 1 | |
TypicalPhlegmaticPerson // 2 | |
TypicalMelancholiac // 3 | |
) |
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 FormatMyValue(i int) string { | |
return fmt.Sprintf(“there are %d my value”, i) | |
} | |
func main() { | |
n := TypicalPhlegmaticPerson | |
fmt.Println(FormatMyValue(n)) | |
} | |
// output: |
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
type CarType int | |
const ( | |
BMW CarType = iota // 0 | |
Audi // 1 | |
Mercedes // 2 | |
_ | |
_ | |
XRay // 5 | |
) |
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
type Permissions int | |
const ( | |
Read Permissions = 1 << iota // 1 << 0 = 00000001 | |
Write // 1 << 1 = 00000010 | |
Create // 1 << 2 = 00000100 | |
Delete // 1 << 3 = 00001000 | |
) |
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
fmt.Println(Write | Delete | Read) | |
// output: | |
// 11 |
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
type ByteSize float64 | |
const ( | |
_ = iota // ignore first value by assigning to blank identifier | |
KB ByteSize = 1 << (10 * iota) // 1 << (10*1) | |
MB // 1 << (10*2) | |
GB // 1 << (10*3) | |
TB // 1 << (10*4) | |
PB // 1 << (10*5) | |
EB // 1 << (10*6) |
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
const ( | |
Russia, USA = iota + 1, iota + 2 | |
Ukraine, Italy | |
China, Spain | |
) | |
// Russia: 1 | |
// USA: 2 | |
// Ukraine: 2 | |
// Italy: 3 |
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 UCFirst(s string) string { | |
return strings.ToUpper(s[:1]) + s[1:] | |
} | |
func LCFirst(s string) string { | |
return strings.ToLower(s[:1]) + s[1:] | |
} |
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
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null | |
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null |
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 sortMap(m map[string]string) []string { | |
list := make(sort.StringSlice, len(m)) | |
i := 0 | |
for name := range m { | |
list[i] = name | |
i++ | |
} | |
list.Sort() | |
result := make([]string, len(list)) | |
for i, name := range list { |
OlderNewer