silenceper/wechat and the shape of a wide, partly unfinished Go SDK
WeChat SDK for Go (simple and easy to use).
At a glance
- What is it?
- One Apache-2.0 Go module covering official accounts, mini programs, mini games, WeChat Pay, the open platform, WeCom and intelligent dialogue. Breadth is the design, per-API coverage is where it gets thin, and the in-repository documentation is short and points outward.
- Who is it for?
- Adopt this if you write Go and need several WeChat product lines from one module instead of maintaining your own XML parsing and token refresh. Skip it if you need one endpoint with tight dependencies: the require block pins golang.org/x/crypto to a 2022-06-22 pseudo-version, and the project asks contributors to check doc/api for the APIs that are not implemented yet.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 11 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- silenceper/wechat5,319 ★ · +15
| Repository | 2026-09-23 | 2026-11-15 |
|---|---|---|
| silenceper/wechat | 5.3k | 5.3k |
15 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The major version lives in the import path
The module is `github.com/silenceper/wechat/v2`, so the major version is part of every import, and the repository default branch is `v2`. go.mod states the same module path and declares `go 1.16`, which sets the floor for the toolchain you build with rather than the version of the WeChat API being targeted. Releases are plain tags: v2.1.12 published 2026-02-11, v2.1.13 on 2026-05-08, v2.1.14 on 2026-07-20. The gaps between those three tags are 86 days and 73 days, and the last push to the repository was on 2026-09-29, so the module is still moving.
module github.com/silenceper/wechat/v2
go 1.16The Cache field decides who holds access_token
Token storage is a field on the config object rather than a package level default. The quick start comment says memcache is used to save access_token, and that redis or a custom cache also work; the example itself fills the field with `cache.NewMemory()`. The config carries `AppID`, `AppSecret`, `Token`, a commented out `EncodingAESKey`, and `Cache`. The repository has top level `cache/` and `credential/` packages, and go.mod requires both `github.com/bradfitz/gomemcache` and `github.com/go-redis/redis/v8`, so the two named backends are backed by real clients rather than an interface you would have to write yourself.
The consequence shows up in deployment rather than in code. An in process memory cache dies with the process, so every restart triggers a fresh token fetch. Several replicas behind one load balancer each fetch their own unless the field points at a shared server. The quick start does not mention this, which means the choice has to be made before the first handler runs rather than after the second replica starts logging in.
GetServer takes the raw request and ResponseWriter
`officialAccount.GetServer(req, rw)` receives the inbound request and the writer directly, as the quick start comment says. `EncodingAESKey` exists on the same config struct and is commented out in the example rather than absent.
The quick start passes `req` and `rw` as bare identifiers, so the caller is expected to already hold both, but nothing there shows a mux setup or a handler func signature to copy.
SetMessageHandler answers messages and nothing else
The handler signature is `func(msg *message.MixMessage) *message.Reply`. It receives a mixed message and returns a reply pointer. The example builds `message.NewText(msg.Content)` and returns `&message.Reply{MsgType: message.MsgTypeText, MsgData: text}`, which echoes whatever the sender typed straight back. That is one shape of reply, not the whole surface.
A mixed message type implies the parser can hand you more than text, yet the only callback registered in the quick start handles messages, and no follow, unsubscribe, scan or menu event appears anywhere in it. What the server does with a nil return is not written down, and neither is whether a second handler can be registered for events alongside this one. If your integration depends on subscribe events, expect to read the API list and the server source instead of following the quick start.
Seven packages split along WeChat's own product lines
The top level tree lists `officialaccount/`, `miniprogram/`, `minigame/`, `pay/`, `openplatform/`, `work/` and `aispeech/`, alongside `cache/`, `credential/`, `domain/`, `internal/`, `util/`, `doc/`, plus the two root files `wechat.go` and `doc.go`. The split is not an internal abstraction: each directory is one WeChat product, which is why payment, the open platform and WeCom ship in the same module as official account messaging.
That breadth pays off if you are building across several of them and costs you if you are not, because everything in the require block comes along, a redis client and a memcache client included, whether or not your endpoint needs them. The contribution instructions make the coverage question explicit. They send contributors to the API list under `doc/api` to see which APIs are not yet implemented, ask for an issue describing the missing piece, and then a pull request. A project that points you at a list of what is missing is telling you that some of it is missing.
Two dependencies are pinned to 2021 and 2022 commits
go.mod mixes semantic versions with pseudo versions. `golang.org/x/crypto` is pinned to `v0.0.0-20220622213112-05595931fe9d` and `github.com/bradfitz/gomemcache` to `v0.0.0-20220106215444-fb4bf637b56d`. A Go pseudo version records the exact commit it resolves to, so those two land on June 2022 and January 2022 snapshots no matter how recent the SDK tags are. The rest of the block sits in the same era: `github.com/stretchr/testify v1.7.1`, `github.com/sirupsen/logrus v1.9.0`, `github.com/spf13/cast v1.4.1`, `github.com/tidwall/gjson v1.14.1`, `github.com/fatih/structs v1.1.0`.
Since the module declares `go 1.16`, minimum version selection in your own project decides the real outcome, and any later fix to the crypto package arrives only when you bump it yourself. The encrypted message path is switched on by a config field, so that pin is worth reading before you lean on it.
require (
github.com/alicebob/miniredis/v2 v2.30.0
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d
github.com/go-redis/redis/v8 v8.11.5
github.com/stretchr/testify v1.7.1
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
)miniredis and gock sit in the main require block
`github.com/alicebob/miniredis/v2 v2.30.0` and `gopkg.in/h2non/gock.v1 v1.1.2` are listed beside the production dependencies rather than in a separate block. gock intercepts outbound HTTP, and miniredis serves a Redis protocol endpoint inside the test process. Their presence says the SDK exercises its calls to WeChat and its redis backed cache against fakes instead of the live service.
That combination is worth reusing in your own code. A handler assembled the same way can run in your test suite with no real credentials, which is the only practical way to check reply marshalling and token cache reuse before the account exists. What the repository does not offer is a walkthrough: the top level tree has no test directory, and the quick start says nothing about running a suite or where fixtures live.
The tutorial lives at silenceper.com and in a separate example repository
The in repository documentation is short by the scope it sets itself: one import line, one example, three links. The API list lives at `github.com/silenceper/wechat/tree/v2/doc/api`, the SDK 2.0 documentation at `https://silenceper.com/wechat/`, and worked examples in a separate repository at `github.com/gowechat/example`. So a first working handler starts from the shape below, copied into your own module with real credentials in place of the placeholders. The `Cache` field here is the in process implementation, and it needs replacing before you run more than one process.
import "github.com/silenceper/wechat/v2"wc := wechat.NewWechat()
memory := cache.NewMemory()
cfg := &offConfig.Config{
AppID: "xxx",
AppSecret: "xxx",
Token: "xxx",
Cache: memory,
}
officialAccount := wc.GetOfficialAccount(cfg)
server := officialAccount.GetServer(req, rw)
server.SetMessageHandler(func(msg *message.MixMessage) *message.Reply {
text := message.NewText(msg.Content)
return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
})Editorial conclusion
Adopt this if you write Go and need several WeChat product lines from one module instead of maintaining your own XML parsing and token refresh. Skip it if you need one endpoint with tight dependencies: the require block pins golang.org/x/crypto to a 2022-06-22 pseudo-version, and the project asks contributors to check doc/api for the APIs that are not implemented yet. Open that list for your exact endpoints first, and decide before writing handlers whether access_token comes from cache.NewMemory() or a shared memcache or redis client.
Frequently asked questions
How do I add the silenceper/wechat SDK to a Go project?
Import the module path `github.com/silenceper/wechat/v2`, which is what the quick start shows, and make sure your toolchain is at least Go 1.16 because that is what go.mod declares. The most recent published tag is v2.1.14 from 2026-07-20.
Where should I keep the WeChat access_token when using silenceper/wechat?
In the `Cache` field of the config struct, which the example fills with `cache.NewMemory()`. The quick start comment also names memcache, redis or a custom cache, and go.mod requires gomemcache and redis/v8 to back the first two.
How do I know which WeChat APIs silenceper/wechat has not implemented?
The README sends contributors to the API list at `doc/api` in the repository to see which APIs are not yet implemented. Check that list for your exact endpoints before settling on this SDK over hand written HTTP calls.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/silenceper-wechat)Star history chart for your README
[](https://hysenlabs.com/projects/silenceper-wechat)Was this useful?