VSCode Snippets

Here’s a VSCode snippet that you can use to easily create encore APIs. Go to Code -> Preferences -> Configure user snippets and then either edit/create a file for Go. Add this and then use enapi [TAB] in your editor to expand the snippet.

{
  "Encore api endpoint": {
    "prefix": "enapi",
    "description": "Encore api defintion and types",
    "body": [
      "type $1Request struct {}",
      "",
      "type $1Response struct {}",
      "",
      "//encore:api $2",
      "func $1(ctx context.Context, req *$1Request) (*$1Response, error) {",
      "\treturn nil, nil",
      "}"
    ]
  }
}
3 Likes

This looks so simple yet so effective. Thank you for submitting this :raised_hands:

This is awesome Will, hope you don’t mind I’ve stolen this live template and embedded it in the upcoming GoLand plugin :slight_smile: