微软copilot玩家-->豆包MarsCode。。 自动化太好了。。

89 阅读1分钟

#豆包MarsCode上新 Apply 能力#

微软copilot玩家-->豆包MarsCode。。 自动化太好了, 真不需要我讲,打开vscode 安装 插件就可以用了。。。

image.png 直接上图:

  1. 提问:handle文件一般是什么干什么处理的 context.Context 详细讲解有什么用?

image.png

package main  
  
import (  
"context"  
  
"2501YTC/app/checkout/biz/service"  
checkout "2501YTC/rpc_gen/kitex_gen/checkout"  
)  
  
// CheckoutServiceImpl implements the last service interface defined in the IDL.  
type CheckoutServiceImpl struct{}  
  
// Checkout implements the CheckoutServiceImpl interface.  
func (s *CheckoutServiceImpl) Checkout(ctx context.Context, req *checkout.CheckoutReq) (resp *checkout.CheckoutResp, err error) {  
resp, err = service.NewCheckoutService(ctx).Run(req)  
  
return resp, err  
}  
  1. apply 生成文件

image.png 3. 函数/doc 之后 再

apply

func main() {  
// 创建一个带有3秒超时的上下文,并返回一个取消函数  
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)  
// 确保在main函数结束时调用取消函数,释放相关资源  
defer cancel()  
  
// 在一个新的goroutine中启动长时间运行的任务,并将上下文传递给它  
go longRunningTask(ctx)  
  
// 等待任务完成或超时  
time.Sleep(5 * time.Second)  
}

image.png

收起