Skip to content

Commit

Permalink
Merge branch 'master' of github.com:TIGERB/easy-tips
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Dec 16, 2018
2 parents 956e925 + 2b0cd6a commit f9292ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion algorithm/sort/bubble.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function bubble_better($value = [])
$value[$i+1] = $tmp;
}
}
$index = $last;
$index = !$flag ? : $last;
}

return $value;
Expand Down
35 changes: 26 additions & 9 deletions go/src/go-learn/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
package main

// 导入net/http包
import (
// 导入net/http包
"net/http"
)

// DemoHandle http handle示例
type DemoHandle struct {
}

// ServeHTTP 匹配到路由后执行的方法
func (DemoHandle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello TIGERB !\n"))
}

func main() {
// 使用http包启动一个http服务
// *http.Request http请求内容实例的指针
// http.ResponseWriter 写http响应内容的实例
http.HandleFunc("/v1/demo", func(w http.ResponseWriter, r *http.Request) {
// 写入响应内容
w.Write([]byte("Hello TIGERB !\n"))
})
// // ------------------ 使用http包启动一个http服务 方式一 ------------------
// // *http.Request http请求内容实例的指针
// // http.ResponseWriter 写http响应内容的实例
// http.HandleFunc("/v1/demo", func(w http.ResponseWriter, r *http.Request) {
// // 写入响应内容
// w.Write([]byte("Hello TIGERB !\n"))
// })
// // 启动一个http服务并监听8888端口
// http.ListenAndServe(":8888", nil)

// ------------------ 使用http包启动一个http服务 方式二 ------------------
// 初始化一个handle
handleDemo := DemoHandle{}

// 启动一个http服务并监听8888端口
http.ListenAndServe(":8888", nil)
http.ListenAndServe(":8888", handleDemo)

}

// 测试我们的服务
Expand Down

0 comments on commit f9292ce

Please sign in to comment.