Skip to content

Instantly share code, notes, and snippets.

View dxavx's full-sized avatar
🏠
Working from home

dxavx dxavx

🏠
Working from home
View GitHub Profile
@dxavx
dxavx / main.go
Last active January 11, 2020 15:19
go validator
package main
import (
"fmt"
"github.com/asaskevich/govalidator"
)
func main() {
str := "https://github.com/asaskevich/govalidator"
@dxavx
dxavx / slice.go
Created January 11, 2020 15:06
Golang slice
package main
import "fmt"
func main() {
// create slice
var buf0 []int // len=0, cap=0
buf1 := []int{} // len=0, cap=0
buf2 := []int{42} // len=1, cap=1
buf3 := make([]int, 0) // len=0, len=0
@dxavx
dxavx / map.go
Created January 11, 2020 09:10
Golang map
package main
import "fmt"
func main() {
// initialization on creation
var user = map[string]string{
"track": "Song-01",
"album": "First",
"codec": "mp3",
@dxavx
dxavx / array.go
Created January 10, 2020 16:52
Golang array
package main
import "fmt"
func main() {
// array size is part of its type
// initialization of default values
var a1 [3]int // [0,0,0]
fmt.Println("a1 short", a1)
fmt.Printf("a1 short %v\n", a1)
@dxavx
dxavx / docker.sh
Created January 9, 2020 14:26
docker delete volumes
# Search for all unnecessary volumes
docker volume ls -f dangling=true
# delete these volumes
docker volume prune
@dxavx
dxavx / docker-compose.yml
Last active January 7, 2020 10:22
Minio docker-compose
version: '3.7'
services:
minio:
image: 'minio/minio'
restart: always
hostname: minio
volumes:
- minio:/data
ports:
@dxavx
dxavx / main.go
Created January 6, 2020 21:21
Content type definition
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
@dxavx
dxavx / control.go
Created January 6, 2020 15:25
Golang if and switch
package main
import "fmt"
func main() {
// simple conditions
boolVal := true
if boolVal {
fmt.Println("boolVal is true")
}
@dxavx
dxavx / loop.go
Created January 6, 2020 13:04
Golang loops
package main
import "fmt"
func main() {
// loop without condition, while(true) OR for(;;;) infinite loop
for {
fmt.Println("loop iteration")
break
}
@dxavx
dxavx / strings.go
Created January 6, 2020 08:10
Golang variables
package main
import (
"fmt"
"unicode/utf8"
)
func main() {
// empty string
var str string