Skip to content

Instantly share code, notes, and snippets.

View qbig's full-sized avatar

Liang qbig

  • @us3r-network
  • Singapore
View GitHub Profile
@qbig
qbig / flags.md
Created August 14, 2018 13:46
Using command-line flags

Working with flags

 package main

        import (
             "flag"
             "fmt"
        )
@qbig
qbig / cmdargs.md
Created August 14, 2018 13:55
Using command-line arguments

Working with commandline arguments

  package main
        import (
            "flag"
            "fmt"
            "os"
        )
        const version = "1.0.0"
@qbig
qbig / env.md
Last active August 15, 2018 06:43
Reading and setting environment variables

Working with env vars

 package envvar

        import (
            "encoding/json"
            "os"

            "github.com/kelseyhightower/envconfig"
@qbig
qbig / config-with-files.md
Created August 14, 2018 14:10
Configuration using TOML, YAML, and JSON

Working with TOML

  package confformat

        import (
            "bytes"

            "github.com/BurntSushi/toml"
        )
@qbig
qbig / unix-pipes.md
Created August 14, 2018 14:13
Working with Unix pipes
package main

        import (
            "bufio"
            "fmt"
            "io"
            "os"
        )
@qbig
qbig / signals.md
Created August 14, 2018 14:17
Catching and handling signals
  package main

        import (
            "fmt"
            "os"
            "os/signal"
            "syscall"
        )
@qbig
qbig / data-convert.md
Created August 15, 2018 16:21
Converting data types and interface casting

Type Casting

    package dataconv

        import "fmt"

        // ShowConv demonstrates some type conversion
        func ShowConv() {
            // int
            var a = 24
@qbig
qbig / numeric.md
Created August 15, 2018 16:33
Working with numeric data types using math and math/big

Working with math

  package math

        import (
         "fmt"
         "math"
        )

        // Examples demonstrates some of the functions
@qbig
qbig / currency-float64.md
Created August 15, 2018 16:43
Currency conversions and float64 considerations

Currency

        package currency

        import (
            "errors"
            "strconv"
            "strings"
        )
@qbig
qbig / encoding-decoding.md
Created August 15, 2018 17:00
Using pointers and SQL NullTypes for encoding and decoding
        package nulls

        import (
            "encoding/json"
            "fmt"
        )

        // json that has name but not age
        const (