{"id":3219,"date":"2025-03-26T00:00:50","date_gmt":"2025-03-25T16:00:50","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=3219"},"modified":"2025-03-26T00:00:50","modified_gmt":"2025-03-25T16:00:50","slug":"go-%e8%af%ad%e8%a8%80%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/03\/26\/go-%e8%af%ad%e8%a8%80%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7\/","title":{"rendered":"Go \u8bed\u8a00\u5f00\u53d1\u5de5\u5177"},"content":{"rendered":"\n<p>Go \u8bed\u8a00\u62e5\u6709\u4e00\u5957\u6210\u719f\u7684\u5f00\u53d1\u5de5\u5177\u94fe\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3001\u4fdd\u8bc1\u4ee3\u7801\u8d28\u91cf\uff0c\u5e76\u7b80\u5316\u6784\u5efa\u548c\u90e8\u7f72\u6d41\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Go \u5f00\u53d1\u5de5\u5177\uff0c\u5305\u62ec IDE\u3001\u7f16\u8f91\u5668\u63d2\u4ef6\u3001\u547d\u4ee4\u884c\u5de5\u5177\u7b49\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Go \u547d\u4ee4\u884c\u5de5\u5177<\/strong><\/h2>\n\n\n\n<p>Go \u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u7ba1\u7406\u9879\u76ee\u3001\u7f16\u8bd1\u4ee3\u7801\u3001\u8fd0\u884c\u6d4b\u8bd5\u7b49\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.1 go run<\/strong><\/h3>\n\n\n\n<p><code>go run<\/code> \u7528\u4e8e\u8fd0\u884c Go \u6e90\u6587\u4ef6\u3002\u5b83\u4f1a\u81ea\u52a8\u7f16\u8bd1\u5e76\u6267\u884c\u6307\u5b9a\u7684 Go \u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go run main.go<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.2 go build<\/strong><\/h3>\n\n\n\n<p><code>go build<\/code> \u7528\u4e8e\u7f16\u8bd1 Go \u6e90\u4ee3\u7801\uff0c\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go build main.go<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u5f53\u524d\u76ee\u5f55\u4e0b\u6709\u591a\u4e2a Go \u6587\u4ef6\uff0c<code>go build<\/code> \u4f1a\u5c06\u6240\u6709\u76f8\u5173\u6587\u4ef6\u7f16\u8bd1\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.3 go test<\/strong><\/h3>\n\n\n\n<p><code>go test<\/code> \u7528\u4e8e\u8fd0\u884c Go \u9879\u76ee\u7684\u5355\u5143\u6d4b\u8bd5\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u547d\u4ee4\u6765\u9a8c\u8bc1\u4ee3\u7801\u7684\u6b63\u786e\u6027\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go test<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.4 go fmt<\/strong><\/h3>\n\n\n\n<p><code>go fmt<\/code> \u7528\u4e8e\u683c\u5f0f\u5316 Go \u4ee3\u7801\uff0c\u4f7f\u5176\u7b26\u5408 Go \u7684\u7f16\u7801\u89c4\u8303\u3002\u5b83\u4f1a\u81ea\u52a8\u4fee\u590d\u7f29\u8fdb\u3001\u7a7a\u683c\u3001\u6362\u884c\u7b49\u683c\u5f0f\u95ee\u9898\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go fmt main.go<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.5 go get<\/strong><\/h3>\n\n\n\n<p><code>go get<\/code> \u7528\u4e8e\u4e0b\u8f7d\u5e76\u5b89\u88c5 Go \u5305\u6216\u6a21\u5757\u3002\u5982\u679c\u4f60\u9700\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go get github.com\/some\/package<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.6 go mod<\/strong><\/h3>\n\n\n\n<p><code>go mod<\/code> \u662f Go \u6a21\u5757\u7ba1\u7406\u5de5\u5177\uff0c\u7528\u4e8e\u7ba1\u7406\u4f9d\u8d56\u5305\u548c\u7248\u672c\u3002Go 1.11 \u5f15\u5165\u4e86\u6a21\u5757\u5316\u652f\u6301\uff0c\u5b83\u66ff\u4ee3\u4e86\u4f20\u7edf\u7684 GOPATH\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go mod init           # \u521d\u59cb\u5316\u6a21\u5757\ngo mod tidy           # \u6e05\u7406\u4e0d\u9700\u8981\u7684\u4f9d\u8d56\ngo mod vendor         # \u5c06\u4f9d\u8d56\u5305\u590d\u5236\u5230 vendor \u6587\u4ef6\u5939<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u548c\u6587\u672c\u7f16\u8f91\u5668<\/strong><\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Go \u8bed\u8a00\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u548c\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u652f\u6301\u7b49\u529f\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.1 Visual Studio Code (VSCode)<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/code.visualstudio.com\/\">Visual Studio Code<\/a> \u662f\u4e00\u4e2a\u514d\u8d39\u7684\u3001\u8f7b\u91cf\u7ea7\u7684\u5f00\u6e90\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5e7f\u53d7 Go \u5f00\u53d1\u8005\u559c\u7231\u3002\u5b83\u652f\u6301\u4e30\u5bcc\u7684\u63d2\u4ef6\u751f\u6001\u7cfb\u7edf\uff0c\u5305\u62ec\u4e13\u4e3a Go \u8bed\u8a00\u5f00\u53d1\u7684\u63d2\u4ef6\u3002\u5b89\u88c5 Go \u63d2\u4ef6\u540e\uff0cVSCode \u63d0\u4f9b\u4e86\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8bed\u6cd5\u9ad8\u4eae<\/li>\n\n\n\n<li>\u81ea\u52a8\u5b8c\u6210<\/li>\n\n\n\n<li>\u4ee3\u7801\u7247\u6bb5<\/li>\n\n\n\n<li>\u8c03\u8bd5\u652f\u6301<\/li>\n\n\n\n<li>Go \u6587\u6863\u67e5\u770b<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u5b89\u88c5 Go \u63d2\u4ef6<\/strong><\/h4>\n\n\n\n<p>\u6253\u5f00 VSCode \u540e\uff0c\u70b9\u51fb\u63d2\u4ef6\u5e02\u573a\u5e76\u641c\u7d22 <code>Go<\/code>\uff0c\u5b89\u88c5\u5b98\u65b9 Go \u63d2\u4ef6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.2 GoLand<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.jetbrains.com\/go\/\">GoLand<\/a> \u662f JetBrains \u5f00\u53d1\u7684\u4e00\u4e2a\u5f3a\u5927\u7684 Go \u4e13\u7528 IDE\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217 Go \u5f00\u53d1\u7684\u529f\u80fd\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f3a\u5927\u7684\u81ea\u52a8\u5b8c\u6210<\/li>\n\n\n\n<li>\u8c03\u8bd5\u5de5\u5177<\/li>\n\n\n\n<li>\u4ee3\u7801\u5206\u6790<\/li>\n\n\n\n<li>\u7248\u672c\u63a7\u5236\u96c6\u6210<\/li>\n\n\n\n<li>Go \u6a21\u5757\u548c\u4f9d\u8d56\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<p>GoLand \u662f\u4e00\u4e2a\u6536\u8d39\u8f6f\u4ef6\uff0c\u4f46\u63d0\u4f9b\u4e86\u8bd5\u7528\u671f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.3 Sublime Text<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.sublimetext.com\/\">Sublime Text<\/a> \u662f\u4e00\u4e2a\u5feb\u901f\u3001\u7b80\u6d01\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u652f\u6301 Go \u5f00\u53d1\u3002\u901a\u8fc7\u5b89\u88c5 GoSublime \u63d2\u4ef6\uff0c\u53ef\u4ee5\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8bed\u6cd5\u9ad8\u4eae<\/li>\n\n\n\n<li>\u81ea\u52a8\u8865\u5168<\/li>\n\n\n\n<li>\u9519\u8bef\u68c0\u67e5<\/li>\n<\/ul>\n\n\n\n<p>Sublime Text \u9700\u8981\u624b\u52a8\u5b89\u88c5\u63d2\u4ef6\uff0c\u4f46\u5b83\u975e\u5e38\u8f7b\u91cf\uff0c\u9002\u5408\u7b80\u5355\u7684 Go \u5f00\u53d1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.4 Atom<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/atom.io\/\">Atom<\/a> \u662f GitHub \u5f00\u53d1\u7684\u4e00\u6b3e\u5f00\u6e90\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5177\u6709\u5f3a\u5927\u7684\u6269\u5c55\u6027\u3002\u4f60\u53ef\u4ee5\u5b89\u88c5 Go-plus \u63d2\u4ef6\u6765\u589e\u5f3a Go \u5f00\u53d1\u4f53\u9a8c\uff0c\u63d0\u4f9b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4ee3\u7801\u9ad8\u4eae<\/li>\n\n\n\n<li>\u81ea\u52a8\u8865\u5168<\/li>\n\n\n\n<li>Go \u8bed\u6cd5\u68c0\u67e5<\/li>\n\n\n\n<li>\u8c03\u8bd5\u652f\u6301<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.5 Vim\/Neovim<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.vim.org\/\">Vim<\/a> \u548c <a href=\"https:\/\/neovim.io\/\">Neovim<\/a> \u662f\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u7f16\u8f91\u5668\u3002\u5b83\u4eec\u901a\u8fc7\u63d2\u4ef6\u652f\u6301 Go \u5f00\u53d1\uff0c\u5982\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>vim-go\uff1a\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u3001\u6d4b\u8bd5\u529f\u80fd\u7b49\u3002<\/li>\n\n\n\n<li>coc.nvim\uff1a\u4e00\u4e2a\u5f3a\u5927\u7684 Language Server Protocol (LSP) \u5ba2\u6237\u7aef\uff0c\u652f\u6301 Go \u8bed\u8a00\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Go \u63d2\u4ef6\u548c\u5de5\u5177<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.1 goimports<\/strong><\/h3>\n\n\n\n<p><code>goimports<\/code> \u662f\u4e00\u4e2a\u7c7b\u4f3c\u4e8e <code>go fmt<\/code> \u7684\u5de5\u5177\uff0c\u9664\u4e86\u683c\u5f0f\u5316\u4ee3\u7801\u5916\uff0c\u5b83\u8fd8\u4f1a\u81ea\u52a8\u6dfb\u52a0\u548c\u5220\u9664 import \u8bed\u53e5\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go get golang.org\/x\/tools\/cmd\/goimports<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.2 golint<\/strong><\/h3>\n\n\n\n<p><code>golint<\/code> \u662f\u4e00\u4e2a Go \u4ee3\u7801\u98ce\u683c\u68c0\u67e5\u5de5\u5177\uff0c\u5b83\u4f1a\u68c0\u67e5\u4f60\u7684\u4ee3\u7801\u662f\u5426\u7b26\u5408 Go \u8bed\u8a00\u7684\u7f16\u7801\u89c4\u8303\u3002\u5b89\u88c5\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go get -u golang.org\/x\/lint\/golint<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.3 gopls<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/github.com\/golang\/tools\/tree\/master\/gopls\">gopls<\/a> \u662f Go \u8bed\u8a00\u7684\u5b98\u65b9\u8bed\u8a00\u670d\u52a1\u5668\uff08LSP\uff09\uff0c\u63d0\u4f9b\u4ee3\u7801\u667a\u80fd\u611f\u77e5\u3001\u81ea\u52a8\u8865\u5168\u3001\u9519\u8bef\u68c0\u67e5\u7b49\u529f\u80fd\u3002\u901a\u8fc7 VSCode \u7b49\u7f16\u8f91\u5668\u96c6\u6210 gopls\uff0c\u53ef\u4ee5\u63d0\u5347 Go \u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n\n\n\n<p>\u5b89\u88c5 gopls\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go get golang.org\/x\/tools\/gopls@latest<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.4 godoc<\/strong><\/h3>\n\n\n\n<p><code>godoc<\/code> \u662f Go \u5b98\u65b9\u63d0\u4f9b\u7684\u6587\u6863\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210 Go \u4ee3\u7801\u7684\u6587\u6863\u548c\u67e5\u770b Go \u5305\u7684 API \u6587\u6863\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b Go \u5305\u7684\u6587\u6863\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>godoc fmt<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. \u8c03\u8bd5\u5de5\u5177<\/strong><\/h2>\n\n\n\n<p>Go \u63d0\u4f9b\u4e86\u4e00\u4e9b\u975e\u5e38\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u8c03\u8bd5 Go \u7a0b\u5e8f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4.1 Delve<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/github.com\/go-delve\/delve\">Delve<\/a> \u662f Go \u5b98\u65b9\u63a8\u8350\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5b83\u652f\u6301\u65ad\u70b9\u8c03\u8bd5\u3001\u5355\u6b65\u6267\u884c\u3001\u67e5\u770b\u53d8\u91cf\u7b49\u529f\u80fd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u5b89\u88c5 Delve<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>go get -u github.com\/go-delve\/delve\/cmd\/dlv<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u4f7f\u7528 Delve \u8c03\u8bd5<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>dlv debug main.go<\/code><\/pre>\n\n\n\n<p>Delve \u53ef\u4ee5\u4e0e IDE \u96c6\u6210\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f7f\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4.2 gdb (GNU Debugger)<\/strong><\/h3>\n\n\n\n<p>Go \u652f\u6301\u4f7f\u7528 GDB \u6765\u8c03\u8bd5 Cgo \u4ee3\u7801\uff0c\u4f46\u5bf9\u4e8e\u7eaf Go \u4ee3\u7801\uff0cDelve \u662f\u66f4\u63a8\u8350\u7684\u5de5\u5177\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Go \u6027\u80fd\u5206\u6790\u5de5\u5177<\/strong><\/h2>\n\n\n\n<p>Go \u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u6765\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5206\u6790\u6027\u80fd\u74f6\u9888\uff0c\u5e76\u4f18\u5316\u4ee3\u7801\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5.1 pprof<\/strong><\/h3>\n\n\n\n<p>Go \u7684\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86 <code>net\/http\/pprof<\/code> \u5305\uff0c\u652f\u6301\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u5206\u6790\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 HTTP \u7aef\u70b9\u66b4\u9732\u6027\u80fd\u5206\u6790\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import (\n    \"net\/http\"\n    _ \"net\/http\/pprof\"\n    \"log\"\n)\n\nfunc main() {\n    go func() {\n        log.Println(http.ListenAndServe(\"localhost:6060\", nil)) \/\/ \u542f\u52a8 pprof \u670d\u52a1\n    }()\n}<\/code><\/pre>\n\n\n\n<p>\u8bbf\u95ee http:\/\/localhost:6060\/debug\/pprof\/ \u8fdb\u884c\u6027\u80fd\u5206\u6790\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5.2 go tool pprof<\/strong><\/h3>\n\n\n\n<p><code>go tool pprof<\/code> \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u5206\u6790 Go \u7a0b\u5e8f\u7684 CPU\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u7b49\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go tool pprof cpu.pprof<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. \u6784\u5efa\u548c\u90e8\u7f72\u5de5\u5177<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6.1 Docker<\/strong><\/h3>\n\n\n\n<p>Docker \u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5bb9\u5668\u5316\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u6784\u5efa\u3001\u6d4b\u8bd5\u548c\u90e8\u7f72 Go \u5e94\u7528\u7a0b\u5e8f\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 Dockerfile \u6765\u6784\u5efa Go \u5e94\u7528\u7a0b\u5e8f\u7684 Docker \u955c\u50cf\uff0c\u5e76\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u8fd0\u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6.2 Kubernetes<\/strong><\/h3>\n\n\n\n<p>Kubernetes \u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5bb9\u5668\u7f16\u6392\u5e73\u53f0\uff0c\u652f\u6301 Go \u5e94\u7528\u7684\u90e8\u7f72\u3001\u6269\u5c55\u548c\u7ba1\u7406\u3002Go \u662f Kubernetes \u7684\u4e3b\u8981\u5f00\u53d1\u8bed\u8a00\uff0c\u719f\u6089 Go \u548c Kubernetes \u662f\u4e00\u4e2a\u6709\u76ca\u7684\u7ec4\u5408\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>Go \u8bed\u8a00\u62e5\u6709\u4e30\u5bcc\u7684\u5f00\u53d1\u5de5\u5177\uff0c\u4ece\u7f16\u8f91\u5668\u63d2\u4ef6\u5230\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u518d\u5230\u8c03\u8bd5\u548c\u6027\u80fd\u5206\u6790\u5de5\u5177\uff0c\u90fd\u80fd\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u4ee5\u4e0b\u662f\u5173\u952e\u5de5\u5177\u7684\u603b\u7ed3\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7f16\u8f91\u5668\u548c IDE<\/strong>\uff1aVSCode\u3001GoLand\u3001Sublime Text\u3001Atom\u3001Vim<\/li>\n\n\n\n<li><strong>\u547d\u4ee4\u884c\u5de5\u5177<\/strong>\uff1ago run\u3001go build\u3001go test\u3001go fmt\u3001go get\u3001go mod<\/li>\n\n\n\n<li><strong>\u8c03\u8bd5\u5de5\u5177<\/strong>\uff1aDelve\u3001gdb<\/li>\n\n\n\n<li><strong>\u6027\u80fd\u5206\u6790<\/strong>\uff1approf\u3001go tool pprof<\/li>\n\n\n\n<li><strong>\u6784\u5efa\u548c\u90e8\u7f72<\/strong>\uff1aDocker\u3001Kubernetes<\/li>\n<\/ul>\n\n\n\n<p>\u9009\u62e9\u9002\u5408\u81ea\u5df1\u5de5\u4f5c\u6d41\u7a0b\u7684\u5de5\u5177\uff0c\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u5f00\u53d1\u548c\u90e8\u7f72 Go \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go \u8bed\u8a00\u62e5\u6709\u4e00\u5957\u6210\u719f\u7684\u5f00\u53d1\u5de5\u5177\u94fe\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3001\u4fdd\u8bc1\u4ee3\u7801\u8d28\u91cf\uff0c\u5e76\u7b80\u5316\u6784\u5efa\u548c\u90e8\u7f72\u6d41\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3220,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":["post-3219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=3219"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3219\/revisions"}],"predecessor-version":[{"id":3221,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3219\/revisions\/3221"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/3220"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=3219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=3219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=3219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}