Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>kt-snippetsNew to Visual Studio Code? Get it now.
kt-snippets

kt-snippets

kt-snippets

|
235 installs
| (0) | Free
公用代码补全工具包
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

kt-snippets README

这是一个内部的公用代码片段 vscode 插件,可在 vscode 市场搜索并安装;

如果这里没有想要的代码片段,可前往仓库 kt-snippets 修改并提交您的代码片段; 我们将会及时更新插件到应用市场,同时会将您添加到贡献者列表中;

VS Code API

werr

返回一个错误

 if err != nil {
 err = xerrors.Errorf("%w", err)
 return
}

funce

type ARequest struct {

}

type AResponse struct {

}

func (e *Endpoints) AEndpoint(ctx context.Context, request *ARequest) (response *AResponse, err error) {

 response = &AResponse{

 }
 return
}

funch

func a(endpoints *endpoint.Endpoints) gin.HandlerFunc {
 return func(c *gin.Context) {
  var input schema.a
  err := c.ShouldBind(&input)
  if err != nil {
   err = xerrors.Errorf("%w", err)
   res.ParamCheckRes(c, err)
   return
  }
  req := input.Transform()
  result, err := endpoints.aEndpoint(c, req)
  if err != nil {
   err = xerrors.Errorf("%w", err)
   res.FailureRes(c, err)
   return
  }
  res.SuccessRes(c, serialize.aTransform(result))
 }
}

sch

type A struct {
 PageIndex int `json:"page_index" form:"page_index" binding:"required,min=1"`
}

func (s *A) Transform() *endpoint.ARequest {
 req := &endpoint.ARequest{
  PageSize:  s.PageSize,
 }
 return req
}

ser

type A struct {

}

func ATransform(e *endpoint.AResponse) *A {
 res := &A{

 }
 return res
}

kerr

 if err != nil {
 err = kerrors.Errorf("%w", err)
 return
}

kt-snippets 发布地址

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft