{"id":20661070,"url":"https://github.com/baetyl/baetyl-go","last_synced_at":"2026-03-17T20:34:01.564Z","repository":{"id":37678124,"uuid":"221669123","full_name":"baetyl/baetyl-go","owner":"baetyl","description":"Golang SDK for BAETYL V2","archived":false,"fork":false,"pushed_at":"2023-12-07T06:34:52.000Z","size":962,"stargazers_count":19,"open_issues_count":2,"forks_count":20,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-19T18:17:25.552Z","etag":null,"topics":["baetyl","grpc","http","mqtt","sdk"],"latest_commit_sha":null,"homepage":"","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/baetyl.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":"2019-11-14T10:19:50.000Z","updated_at":"2025-01-03T21:48:26.000Z","dependencies_parsed_at":"2023-02-18T04:05:16.175Z","dependency_job_id":"2ee5e927-20c2-4b3b-be56-1e2c00eff085","html_url":"https://github.com/baetyl/baetyl-go","commit_stats":null,"previous_names":[],"tags_count":217,"template":false,"template_full_name":null,"purl":"pkg:github/baetyl/baetyl-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baetyl%2Fbaetyl-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baetyl%2Fbaetyl-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baetyl%2Fbaetyl-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baetyl%2Fbaetyl-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baetyl","download_url":"https://codeload.github.com/baetyl/baetyl-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baetyl%2Fbaetyl-go/sbom","scorecard":{"id":223022,"data":{"date":"2025-08-11","repo":{"name":"github.com/baetyl/baetyl-go","commit":"0ca215be0695c5fa4d4909463ec7cc33f4fae6bb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/unittest.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittest.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/baetyl/baetyl-go/unittest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittest.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/baetyl/baetyl-go/unittest.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/unittest.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/baetyl/baetyl-go/unittest.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"17 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2023-2412 / GHSA-7ww5-4wqc-m92c","Warn: Project is vulnerable to: GO-2025-3528 / GHSA-265r-hfxg-fhmg","Warn: Project is vulnerable to: GO-2023-1737 / GHSA-2c4m-59x9-fr2g","Warn: Project is vulnerable to: GHSA-h74j-692g-48mq","Warn: Project is vulnerable to: GO-2025-3605 / GHSA-7vpp-9cxj-q8gv","Warn: Project is vulnerable to: GO-2024-2698 / GHSA-rhh4-rh7c-7r5v","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T03:03:25.827Z","repository_id":37678124,"created_at":"2025-08-17T03:03:25.827Z","updated_at":"2025-08-17T03:03:25.827Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30631239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["baetyl","grpc","http","mqtt","sdk"],"created_at":"2024-11-16T19:07:01.010Z","updated_at":"2026-03-17T20:34:01.534Z","avatar_url":"https://github.com/baetyl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"baetyl-go\n========\n\n[![codecov](https://codecov.io/gh/baetyl/baetyl-go/branch/master/graph/badge.svg)](https://codecov.io/gh/baetyl/baetyl-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/baetyl/baetyl-go)](https://goreportcard.com/report/github.com/baetyl/baetyl-go) \n[![License](https://img.shields.io/github/license/baetyl/baetyl-go.svg)](./LICENSE)\n\n# Golang SDK for BAETYL V2\n\nPlease use [Old SDK](https://github.com/baetyl/baetyl/tree/stable/1/sdk/baetyl-go) if working on [BAETYL V1](https://github.com/baetyl/baetyl).\n\n# baetyl-go Document\nYou can use Baetyl SDK to develop moduels with Golang language. It is in baetyl-go warehouse. The functional interface is Context.\n\nAt present, the provided SDK capabilities are still relatively limited, and will be gradually strengthened in the future. Other languasges will be supported in future.\n\n## 1. Version\nversion：git-6a9a8f8\n\n## 2. Basic Function\nUser developed custom modules can access features provided by baetyl SDK when launch it from the Context defined by baetyl-go.\n\nCalling method：\n\n```go\ncontext.Run(func(ctx context.Context) error\n   // business logic\n   ......\n\n\n   return nil\n}\n```\n\nContext  api：\n\n```go\n// Context of service\n// Baetyl runtime context\ntype Context interface {\n   // NodeName returns node name from data.\n   NodeName() string\n   // AppName returns app name from data.\n   AppName() string\n   // AppVersion returns application version from data.\n   AppVersion() string\n   // ServiceName returns service name from data.\n   ServiceName() string\n   // ConfFile returns config file from data.\n   ConfFile() string\n\n   // SystemConfig returns the config of baetyl system from data.\n   SystemConfig() *SystemConfig\n\n   // Log returns logger interface.\n   Log() *log.Logger\n\n   // Wait waits until exit, receiving SIGTERM and SIGINT signals.\n   Wait()\n   // WaitChan returns wait channel.\n   WaitChan() \u003c-chan os.Signal\n\n   // Load returns the value stored in the map for a key, or nil if no value is present.\n   // The ok result indicates whether value was found in the map.\n   Load(key interface{}) (value interface{}, ok bool)\n   // Store sets the value for a key.\n   Store(key, value interface{})\n   // LoadOrStore returns the existing value for the key if present.\n   // Otherwise, it stores and returns the given value.\n   // The loaded result is true if the value was loaded, false if stored.\n   LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)\n   // Delete deletes the value for a key.\n   Delete(key interface{})\n\n   // CheckSystemCert checks system certificate, if certificate is not found or invalid, returns an error.\n   CheckSystemCert() error\n   // LoadCustomConfig loads custom config.\n   // If 'files' is empty, will load config from default path,\n   // else the first file path will be used to load config from.\n   LoadCustomConfig(cfg interface{}, files ...string) error\n   // NewFunctionHttpClient creates a new function http client.\n   NewFunctionHttpClient() (*http.Client, error)\n   // NewSystemBrokerClientConfig creates the system config of broker\n   NewSystemBrokerClientConfig() (mqtt.ClientConfig, error)\n   // NewBrokerClient creates a new broker client.\n   NewBrokerClient(mqtt.ClientConfig) (*mqtt.Client, error)\n   // NewSystemBrokerClient creates a new system broker client.\n   NewSystemBrokerClient([]mqtt.QOSTopic) (*mqtt.Client, error)\n}\n```\n\n## 3. Examples\nThe following takes the implementation of the function module as an example to briefly introduce the usage of baetyl-go.\nproject address：[baetyl-function](https://github.com/baetyl/baetyl-function/blob/master/cmd/main.go) \n\n```go\n// Config: function \ntype Config struct {\n\tServer http.ServerConfig `yaml:\"server\" json:\"server\"`\n\tClient ClientConfig      `yaml:\"client\" json:\"client\"`\n}\n\ntype ClientConfig struct {\n\tGrpc GrpcConfig `yaml:\"grpc\" json:\"grpc\"`\n}\n\ntype GrpcConfig struct {\n\tPort    int           `yaml:\"port\" json:\"port\" default:\"80\"`\n\tTimeout time.Duration `yaml:\"timeout\" json:\"timeout\" default:\"5m\"`\n\tRetries int           `yaml:\"retries\" json:\"retries\" default:\"3\"`\n}\n\n\n\n// program entry\nfunc main() {\n    // start service through the context of baetyl-go \n\tcontext.Run(func(ctx context.Context) error {\n        // Check if system certificate exists\n\t\tif err := ctx.CheckSystemCert(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tvar cfg function.Config\n        // load custom config \n\t\terr := ctx.LoadCustomConfig(\u0026cfg)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\n        // Create a parser to get the running mode of the current application through context.RunMode() \n\t\tresolver, err := resolve.New(context.RunMode(), ctx)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tdefer resolver.Close()\n\n        // create and start function http service\n\t\tapi, err := function.NewAPI(cfg, ctx, resolver)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tdefer api.Close()\n\n\n        // wait to exit, listening SIGTERM and SIGINI signal\n\t\tctx.Wait()\n\t\treturn nil\n\t})\n}\n```\n\nfunction config file\n\n```yaml\nserver: # server config.Runtimes module that proxies requests to the backend\n  address: \":50011\" # listening address\n  concurrency: # The number of concurrent connections on the server side, if not set, the default value will be used\n  disableKeepalive: true # Whether to enable keep-alive connection, the default value is false\n  tcpKeepalive: false # Whether to send keep-alive connection, the default value is false\n  maxRequestBodySize: # Body max connection number，default value is 4 * 1024 * 1024 Byte\n  readTimeout: 1h # read timeout of server connection，default time is unlimited\n  writeTimeout: 1h # write timeout of server connection ,default time is unlimited \n  idleTimeout: 1h # when keep alive is started,Under keep alive start condition, the server waits for the idle timeout time of the next message, if the value is 0, multiplex read timeout time\n  ca: example/var/lib/baetyl/testcert/ca.crt # Server  CA path\n  key: example/var/lib/baetyl/testcert/server.key # Server private key path\n  cert: example/var/lib/baetyl/testcert/server.crt # Server public key path\n\nclient: # Requests client-side related settings for the backend Runtimes module\n  grpc: # Grpc client setting\n    port: 80 #  Runtimes port\n    timeout: 5m # Request timeout\n    retries: 3 # Request retries\n\nlogger: # log\n  level: info # log level\n```\n\n## 4. Other Method\nThis Chapter introduces the features and function of some usefule packages.\n\nYou can find more function api with godoc tool. Refer to Chapter 5 to see how to install and use godoc\n\n### 4.1 context pakage\n#### 4.1.1 env\n```go\n// HostPathLib return HostPathLib\nfunc HostPathLib() (string, error)\n// RunMode return run mode of edge.\nfunc RunMode() string\n// EdgeNamespace return namespace of edge.\nfunc EdgeNamespace() string\n// EdgeSystemNamespace return system namespace of edge.\nfunc EdgeSystemNamespace() string\n// BrokerPort return broker port.\nfunc BrokerPort() string\n// FunctionPort return http port of function.\nfunc FunctionHttpPort() string\n// BrokerHost return broker host.\nfunc BrokerHost() string\n// FunctionHost return function host.\nfunc FunctionHost() string\n```\n\n#### 4.1.2 platform\n```go\n// return platform info\n// specs.Platform{\n//    OS:           runtime.GOOS,\n//    Architecture: runtime.GOARCH,\n//    // The Variant field will be empty if arch != ARM.\n//    Variant: cpuVariant,\n// }\nfunc Platform() PlatformInfo\n// Returns a string of platform information in the following format\n// \"%s-%s-%s\", pl.OS, pl.Architecture, pl.Variant\nfunc PlatformString() string\n```\n\n### 4.2 http package\nThis package provides http service. You can use the program to complete quick initialization, start http server/client, initiate http request and other functions\n\n#### 4.2.1 client\n```go\n// NewClient creates a new http client\nfunc NewClient(ops *ClientOptions) *Client\n\n\n// Call calls the function via HTTP POST\nfunc (c *Client) Call(function string, payload []byte) ([]byte, error)\n// PostJSON post data with json content type\nfunc (c *Client) PostJSON(url string, payload []byte, headers ...map[string]string)\n// GetJSON get data with json content type\nfunc (c *Client) GetJSON(url string, headers ...map[string]string) ([]byte, error)\nfunc (c *Client) GetURL(url string, header ...map[string]string) \nfunc (c *Client) PostURL(url string, body io.Reader, header ...map[string]string)\nfunc (c *Client) SendUrl(method, url string, body io.Reader, header ...map[string]string)\n```\n\n#### 4.2.2 server\n```go\n// NewServer new server\nfunc NewServer(cfg ServerConfig, handler fasthttp.RequestHandler) *Server\n\n\nfunc (s *Server) Start()\nfunc (s *Server) Close()\n```\n\n## 4.3 pki package\nEncapsulate goalng's certificate generation and issuance to provide more convenient certificate operation functions\n\n* Support the issuance of root certificates\n* Support the issuance of self-signed root certificates\n* Support the issuance of sub-certificates\n* Support the issuance of sub-certificates with specified private keys\n\n## 4.4 pubsub package\nThis package provides a memory version of the message queue mechanism that supports publishing and subscription\n\n* Support topic subscription and unsubscription\n* Support news release\n* Provide an executor that can quickly start a message receiving processor that supports timeout settings\n\n## 4.5 plugin package\nThis package provides registration mechanism based on the factory mode\n\n## 4.6 tools package\n  This package provides a sample program for certificate issuance\n  \n## 4.7 utils package\nThis package provides help function\n\n* Certificate parsing\n* Configuration parsing\n* Default value setting\n* Log tracking\n* Support zip compression\n  \n## 4.8 dmcontext package\n  Context functions that provide device management functionality \n  \n# 5.GoDoc\nhow to find api document using godoc\n  1. Install godoc `go get golang.org/x/tools/cmd/godoc`\n  2. make sure godoc is under gosrc path\n  3. godoc -http=:6060 The interface is set according to the actual situation\n  4. visit following address in broswer `http://0.0.0.0:6060/pkg/`\n  5. check baetyl-go document\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaetyl%2Fbaetyl-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaetyl%2Fbaetyl-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaetyl%2Fbaetyl-go/lists"}