Skip to content

Instantly share code, notes, and snippets.

@slntopp
Last active May 14, 2024 13:19
Show Gist options
  • Save slntopp/76dd4d3cea14475aca482a595fc0cba8 to your computer and use it in GitHub Desktop.
Save slntopp/76dd4d3cea14475aca482a595fc0cba8 to your computer and use it in GitHub Desktop.
VS Code Regex to Replace On With Expect clause (mockery)

Find and replace all mock.On to Expecter

Find all:

On\("(.+)",\s

Replace with:

EXPECT().$1(

Find and replace all struct mocks to fabric

Find all:

&mocks.(.+)\{\}

Replace with

mocks.New$1(t)

Update SQLc config from v1 to v2

Find all

- name: "(\w+)"\n\s+path: (".+")\n\s+(engine: .+)\n\s+(schema: .+)\n\s+(queries: .+)\n\s+emit_interface: true

Replace with

- name: "$1"
  $3
  $4
  $5
  gen:
    go:
      package: "$1"
      out: $2
      emit_interface: true

Additionally should change version to "2", remove "project" if present and rename key packages to sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment