Go\u8bed\u8a00\u5c01\u88c5exe\uff1a\u539f\u7406\u4e0e\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n
Go\u8bed\u8a00\uff0c\u53c8\u79f0Golang\uff0c\u662f\u4e00\u79cd\u7f16\u8bd1\u578b\u3001\u9759\u6001\u7c7b\u578b\u3001\u5e76\u53d1\u578b\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\u3002Go\u8bed\u8a00\u4e3b\u8981\u5173\u6ce8\u7cfb\u7edf\u7f16\u7a0b\u548c\u5e76\u53d1\u6027\u80fd\u3002\u5c01\u88c5exe\u662f\u6307\u901a\u8fc7Go\u7f16\u8bd1\u751f\u6210\u4e00\u4e2a\u72ec\u7acb\u53ef\u6267\u884c\u6587\u4ef6\uff08executable\uff09\uff0c\u90e8\u7f72\u548c\u5206\u53d1\u65f6\u4e0d\u9700\u8981\u5176\u4ed6\u4f9d\u8d56\uff0c\u8fd9\u4f7f\u5f97Go\u5e94\u7528\u7a0b\u5e8f\u975e\u5e38\u65b9\u4fbf\u5730\u5728Windows\u7cfb\u7edf\u4e0a\u90e8\u7f72\u548c\u5206\u53d1\u3002\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Go\u8bed\u8a00\u8fdb\u884c\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5c01\u88c5\u3002<\/p>\n
\u4e00\u3001\u5c01\u88c5\u539f\u7406<\/p>\n
Go\u8bed\u8a00\u751f\u6210\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e0e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u751f\u6210\u7684\u6587\u4ef6\u6709\u6240\u4e0d\u540c\uff0c\u5b83\u4f1a\u81ea\u52a8\u5c06\u7a0b\u5e8f\u7684\u4f9d\u8d56\u548c\u8fd0\u884c\u65f6\u6253\u5305\u5230\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\uff0c\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u9759\u6001\u7f16\u8bd1\u3002\u8fd9\u4f7f\u5f97\u751f\u6210\u5982\u4f55\u5c06m\u6587\u4ef6\u8f6c\u6362\u4e3aexe\u683c\u5f0f<\/a>\u7684\u6587\u4ef6\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u8fd0\u884c\u65f6\u4e0d\u9700\u8981\u989d\u5916\u7684\u52a8\u6001\u94fe\u63a5\u5e93\uff0c\u4ece\u800c\u907f\u514d\u4e86\u7248\u672c\u4e0d\u5339\u914d\u7b49\u95ee\u9898\u3002\u8fd9\u4f7f\u5f97Go\u975e\u5e38\u9002\u5408\u7f16\u8bd1\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u800c\u65e0\u9700\u5176\u4ed6\u4f9d\u8d56\u3002<\/p>\n
\u4e8c\u3001\u7f16\u8bd1\u6210exe\u6b65\u9aa4<\/p>\n
olang.org\/dl\/\uff09\u4e0b\u8f7d\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Go\u7f16\u8bd1\u5668\u5b89\u88c5\u6587\u4ef6\uff0c\u5e76\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n
2. \u7f16\u5199Go\u4ee3\u7801\uff1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`main.go`\u7684\u6587\u4ef6\uff0c\u5e76\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Go\u7a0b\u5e8f\uff1a<\/p>\n
“`golang<\/p>\n
package main<\/p>\n
import “fmt”<\/p>\n
func main() {<\/p>\n
fmt.Println(“Hello, world!”)<\/p>\n
}<\/p>\n
“`<\/p>\n
3. \u751f\u6210exe\u6587\u4ef6\uff1a<\/p>\n
\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\uff0c\u6ce8\u610f\u5c06`your_app_name.exe`\u66ff\u6362\u6210\u4f60\u671f\u671b\u7684exe\u6587\u4ef6\u540d\uff0c\u4f8b\u5982`hello.exe`\u3002<\/p>\n
“`shell<\/p>\n
go build -o your_app_name.exe main.go <\/p>\n
“`<\/p>\n
\u6267\u884c\u6b64\u547d\u4ee4\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u6587\u4ef6\u5939\u751f\u6210\u4e00\u4e2a\u540d\u4e3a`your_app_name.exe`\u7684exe\u6587\u4ef6\u3002<\/p>\n
4. \u8fd0\u884cexe\u6587\u4ef6\uff1a\u53cc\u51fb`your_app_name.exe`\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884cGo\u7a0b\u5e8f\u4e86\u3002\u7a0b\u5e8f\u8fd0\u884c\u5b8c\u6210\u540e\uff0c\u4f1a\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u51fa”Hello, wopyd\u6253\u5305exe\u5931\u8d25<\/a>rld!”\u3002<\/p>\n
\u4e09\u3001\u8de8\u5e73\u53f0\u7f16\u8bd1<\/p>\n
1. \u5728Linux\u6216Mac\u4e0a\u4e3aWindows\u7f16\u8bd1\uff1a<\/p>\n
GOOS=windows GOARCH=amd64 go build -o your_app_name.exe main.go<\/p>\n
2. \u5728Windows\u4e0a\u4e3aLinux\u7f16\u8bd1\uff1a<\/p>\n
go build -o your_app_name main.go<\/p>\n
3. \u5728Windows\u4e0a\u4e3aMac\u7f16\u8bd1\uff1a<\/p>\n
go build -o your_app_name main.go<\/p>\n