Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Add / Remove Struct Tags #12

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This tool provides the information needed to compute the various test code lense

This tool provides support for the [`Go: Run on Go Playground`](features.md#go-playground) command.

### [`gomodifytags`](https://pkg.go.dev/github.com/fatih/gomodifytags?tab=overview)
### [`gopmodifytags`](https://pkg.go.dev/github.com/goplus/gopmodifytags?tab=overview)

This tool provides support for the [`Go: Add Tags to Struct Fields`](features.md#add-or-remove-struct-tags) and [`Go: Remove Tags From Struct Fields`](features.md#add-or-remove-struct-tags) commands.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@
{
"command": "gop.add.tags",
"title": "Go+: Add Tags To Struct Fields",
"description": "Add tags configured in go.addTags setting to selected struct using gomodifytags"
"description": "Add tags configured in go.addTags setting to selected struct using gopmodifytags"
},
{
"command": "gop.remove.tags",
"title": "Go+: Remove Tags From Struct Fields",
"description": "Remove tags configured in go.removeTags setting from selected struct using gomodifytags"
"description": "Remove tags configured in go.removeTags setting from selected struct using gopmodifytags"
},
{
"command": "gop.fill.struct",
Expand Down
8 changes: 4 additions & 4 deletions src/goModifytags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getCommonArgs(): string[] {
vscode.window.showInformationMessage('No editor is active.');
return [];
}
if (!editor.document.fileName.endsWith('.go')) {
if (!editor.document.fileName.endsWith('.go') && !editor.document.fileName.endsWith('.gop')) {
vscode.window.showInformationMessage('Current file is not a Go file.');
return [];
}
Expand Down Expand Up @@ -162,22 +162,22 @@ function getTagsAndOptions(config: GoTagsConfig, commandArgs: GoTagsConfig): The
}

function runGomodifytags(args: string[]) {
const gomodifytags = getBinPath('gomodifytags');
const gomodifytags = getBinPath('gopmodifytags');
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
const input = getFileArchive(editor.document);
const p = cp.execFile(gomodifytags, args, { env: toolExecutionEnvironment() }, (err, stdout, stderr) => {
if (err && (<any>err).code === 'ENOENT') {
promptForMissingTool('gomodifytags');
promptForMissingTool('gopmodifytags');
return;
}
if (err && (<any>err).code === 2 && args.indexOf('--template') > 0) {
vscode.window.showInformationMessage(
'Cannot modify tags: you might be using a' + 'version that does not support --template'
);
promptForUpdatingTool('gomodifytags');
promptForUpdatingTool('gopmodifytags');
return;
}
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function getConfiguredTools(
'guru',
'gorename',
'gotests',
'gomodifytags',
'gopmodifytags',
'impl',
'fillstruct',
'goplay',
Expand Down
10 changes: 5 additions & 5 deletions src/goToolsInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: false,
description: 'Rename symbols'
},
'gomodifytags': {
name: 'gomodifytags',
importPath: 'github.com/fatih/gomodifytags',
modulePath: 'github.com/fatih/gomodifytags',
'gopmodifytags': {
name: 'gopmodifytags',
importPath: 'github.com/goplus/gopmodifytags',
modulePath: 'github.com/goplus/gopmodifytags',
replacedByGopls: false,
isImportant: false,
description: 'Modify tags on structs',
defaultVersion: 'v1.16.0'
defaultVersion: 'v1.0.0'
},
'goplay': {
name: 'goplay',
Expand Down
10 changes: 5 additions & 5 deletions tools/allTools.ts.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: false,
description: 'Rename symbols'
},
'gomodifytags': {
name: 'gomodifytags',
importPath: 'github.com/fatih/gomodifytags',
modulePath: 'github.com/fatih/gomodifytags',
'gopmodifytags': {
name: 'gopmodifytags',
importPath: 'github.com/goplus/gopmodifytags',
modulePath: 'github.com/goplus/gopmodifytags',
replacedByGopls: false,
isImportant: false,
description: 'Modify tags on structs',
defaultVersion: 'v1.16.0'
defaultVersion: 'v1.0.0'
},
'goplay': {
name: 'goplay',
Expand Down
Loading