INNER CODE UNIT · Go

capturePrint

wgpsec/cloudsword · cmd/mcpServer.go:17

func capturePrint(f func()) string {
	old := os.Stdout
	r, w, _ := os.Pipe()
	os.Stdout = w
	f() // 调用包含 fmt.Print 的函数
	w.Close()
	os.Stdout = old
	var buf bytes.Buffer
	io.Copy(&buf, r)
	return buf.String()
}

func fnModel(m global.Module) server.ToolHandlerFunc {
	return func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
		for _, b := range global.GetBasicOptionsWithId(m.ID) {
			v, ok := req.Params.Arguments[b.Key].(string)
			if !ok && b.Required {
				return nil, fmt.Errorf("invalid name parameter%s", b.Key)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…