Skip to content

Instantly share code, notes, and snippets.

View scbizu's full-sized avatar
🤗
用代码给大家带来笑容 Bring smiles with codes

Nace Sc scbizu

🤗
用代码给大家带来笑容 Bring smiles with codes
View GitHub Profile
@scbizu
scbizu / md5-example.go
Last active February 7, 2017 07:47 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
//hasher is a `io.Writer`
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
@scbizu
scbizu / Tracing.go
Created February 6, 2017 04:03
[HTTP Tracing]HTTP Tracing with http.RoundTripper wrapper #tags:Go
package main
import (
"fmt"
"log"
"net/http"
"net/http/httptrace"
)
// transport is an http.RoundTripper that keeps track of the in-flight
@scbizu
scbizu / testlepton.go
Created February 6, 2017 03:38
[test]Lepton Test #tags:Lepton,golang
package main
import (
"fmt"
)
func main(){
fmt.Println("Hello Lepton")
}
@scbizu
scbizu / jparse.go
Created August 19, 2016 17:53
golang json.Indent() 的一种实现
package jparse
import (
"bytes"
"encoding/json"
)
func newline(dst *bytes.Buffer, depth int) {
dst.WriteByte('\n')
@scbizu
scbizu / json_format.go
Created August 1, 2016 16:42
struct to json
package main
import (
"encoding/json"
"fmt"
)
type JsonFor struct {
Foo string `json:"foo"`
Foo_s string `json:"foo_s,string"`
@scbizu
scbizu / closure_OFP.go
Created June 6, 2016 06:46
函数编程思维的闭包例子的Golang实现
package main
import "fmt"
type Studnet struct {
name string
age int
}
func Average(age int) func(stu *Studnet) bool {
@scbizu
scbizu / stack.go
Created May 31, 2016 03:40
LIFO stack golang
//Stack Golang
package main
import "fmt"
type Element struct {
next *Element
val interface{}
}
@scbizu
scbizu / oop_method.go
Created May 30, 2016 16:50
golang oop practice(method and some oop features)
package main
import "fmt"
type human struct {
age int
name string
}
//继承
@scbizu
scbizu / Maxprocs.go
Created May 30, 2016 11:20
Test golang Maxprocs
package main
import (
"fmt"
// "runtime"
)
/*
*Question:
*Test GOMAXPROCS
@scbizu
scbizu / Multi_thread.go
Created May 30, 2016 10:40
an example for how to make mutil-thread code with Golang
package main
import "fmt"
/*
*Question:
*使用Channel堵塞主线程 等待Gor GO完
*/
var chan1 chan int = make(chan int)