
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
github.com/issue9/assert/v2
assert 包是对 testing 的一个简单扩展,提供的一系列的断言函数, 方便在测试函数中使用:
func TestA(t *testing.T) {
v := true
assert.True(v, false)
a := assert.New(t)
a.True(v)
}
// 也可以对 testing.B 使用
func Benchmark1(b *testing.B) {
a := assert.New(b, false)
v := false
a.True(v)
for(i:=0; i<b.N; i++) {
// do something
}
}
// 对 API 请求做测试,可以引用 assert/rest
func TestHTTP( t *testing.T) {
a := assert.New(t, false)
srv := rest.NewServer(a, h, nil)
a.NotNil(srv)
defer srv.Close()
srv.NewRequest(http.MethodGet, "/body").
Header("content-type", "application/json").
Query("page", "5").
JSONBody(&bodyTest{ID: 5}).
Do().
Status(http.StatusCreated).
Header("content-type", "application/json;charset=utf-8").
JSONBody(&bodyTest{ID: 6})
}
也可以直接对原始数据进行测试。
// 请求数据
req :=`POST /users HTTP/1.1
Host: example.com
Content-type: application/json
{"username": "admin", "password":"123"}
`
// 期望的返回数据
resp :=`HTTP/1.1 201
Location: https://example.com/users/1
`
func TestRaw(t *testing.T) {
a := assert.New(t, false)
rest.RawHTTP(a, nil,req, resp)
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.