forked from TIGERB/easy-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
253 additions
and
132 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"unsafe" | ||
// 导入net/http包 | ||
"net/http" | ||
"os" | ||
"runtime/trace" | ||
) | ||
|
||
type flightGroup interface { | ||
// Done is called when Do is done. | ||
Do(key string, fn func() (interface{}, error)) (interface{}, error) | ||
} | ||
|
||
// golangci-lint run --disable-all -E maligned | ||
func main() { | ||
//创建trace文件 | ||
f, err := os.Create("trace.out") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
type Demo struct { | ||
A int8 | ||
B int64 | ||
C int8 | ||
} | ||
defer f.Close() | ||
|
||
type DemoTwo struct { | ||
A int8 | ||
C int8 | ||
B int64 | ||
} | ||
//启动trace goroutine | ||
err = trace.Start(f) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer trace.Stop() | ||
|
||
func main() { | ||
demo := Demo{} | ||
demoTwo := DemoTwo{} | ||
fmt.Println(unsafe.Sizeof(demo), unsafe.Sizeof(demoTwo)) | ||
// ------------------ 使用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端口 这里第二个参数可以指定handler | ||
http.ListenAndServe(":8888", nil) | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.