{"id":19411485,"url":"https://github.com/volcengine/vefaas-golang-runtime","last_synced_at":"2025-04-24T10:33:41.612Z","repository":{"id":43959052,"uuid":"473478488","full_name":"volcengine/vefaas-golang-runtime","owner":"volcengine","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-26T08:06:00.000Z","size":21,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T03:51:13.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/volcengine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T06:09:45.000Z","updated_at":"2025-03-26T08:06:04.000Z","dependencies_parsed_at":"2024-11-10T12:39:45.473Z","dependency_job_id":null,"html_url":"https://github.com/volcengine/vefaas-golang-runtime","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvefaas-golang-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvefaas-golang-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvefaas-golang-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvefaas-golang-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/volcengine","download_url":"https://codeload.github.com/volcengine/vefaas-golang-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250609262,"owners_count":21458455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T12:21:39.025Z","updated_at":"2025-04-24T10:33:41.345Z","avatar_url":"https://github.com/volcengine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# veFaaS Golang 运行时\n\n用于开发 veFaaS Golang 函数的 SDK 及代码样例，更多信息请参考 [Golang 函数开发指南](https://www.volcengine.com/docs/6662/106051)。\n\n## 快速上手\n```Golang\n// main.go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/volcengine/vefaas-golang-runtime/events\"\n\t\"github.com/volcengine/vefaas-golang-runtime/vefaas\"\n\t\"github.com/volcengine/vefaas-golang-runtime/vefaascontext\"\n)\n\nfunc main() {\n\t// Start your vefaas function =D.\n\tvefaas.Start(handler)\n}\n\n// Define your handler function.\nfunc handler(ctx context.Context, r *events.HTTPRequest) (*events.EventResponse, error) {\n\tfmt.Printf(\"request id: %s\", vefaascontext.RequestIdFromContext(ctx))\n\tfmt.Printf(\"request headers: %v\", r.Headers)\n\n\treturn \u0026events.EventResponse{\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tBody: []byte(\"Hello veFaaS!\"),\n\t}, nil\n}\n```\n\n## 构建 veFaaS Golang 函数\n对于 veFaaS Golang 运行时函数，在部署之前，开发者需要将其在本地构建为可在 Linux 环境 amd64 架构下执行的、命名为 main 的二进制文件，并将其打包在 .zip 文件中。\n\n### 对于 Linux/macOS 开发者\n可通过如下 shell 指令对程序进行编译和打包：\n```shell\n# Build your program that's executable for Linux under architecture amd64.\nGOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main\n# Zip output.\nzip main.zip main\n```\n### 对于 Windows 开发者\n\n1. 通过快捷键 `Windows + R` 唤出命令窗口，输入 `wt` 并键入 `Enter` 打开命令行终端。通过以下命令执行编译：\n```shell\nset GOOS=linux\nset GOARCH=amd64\nset CGO_ENABLED=0\ngo build -o main\n```\n2. 使用打包工具对编译好的二进制 `main` 进行打包，`main` 需要位于 .zip 文件根目录下。\n\n\n## 发布 veFaaS Golang 函数\n对于 Golang 这类编译型函数，veFaaS 暂不支持通过控制台在线编辑函数进而构建和发布，需要开发者在本地进行代码开发，按照 [构建 veFaaS Golang 函数](#构建-vefaas-golang-函数) 中的步骤对函数编译和打包，然后将打包好的 .zip 文件上传至 veFaaS 控制台，进行函数发布。\n\n\n## 注意事项\n- 编译后的二进制文件须为命名为 main 的、可在 Linux 环境 amd64 架构下执行的二进制文件\n- 打包后的 main 须位于 .zip 文件的根目录下，不能嵌套在其它文件夹下\n- 如果主程序的执行依赖其它本地文件，如 config.yaml，在打包 .zip 文件时，这些文件依赖要一同打包，代码中通过相对位置来进行引用\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fvefaas-golang-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolcengine%2Fvefaas-golang-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fvefaas-golang-runtime/lists"}