GoTagMate is a powerful and user-friendly VSCode extension designed to simplify working with Go struct tags. It provides intelligent suggestions, autocompletion, and detailed documentation for popular Go libraries like json, gorm, and validate. Whether you're a beginner or an experienced Go developer, GoTagMate will save you time and reduce errors when writing struct tags.
- bson
- attributevalue
- env/v11
- gin
- gohcl
- hcl
- json
- msgpack
- binding-and-validation
- gorm
- go-redis/v9
- redigo/redis
- toml
- go-toml
- validator/v10
- xml
- yaml.v3
- bun
- conform
-
Automatic Suggestions:
- As soon as you type a backtick (`) in a Go struct, GoTagMate will suggest popular tag options like
json:"",gorm:"", andvalidate:"".
- As soon as you type a backtick (`) in a Go struct, GoTagMate will suggest popular tag options like
-
Context-Aware Autocompletion:
- After selecting a tag (e.g.,
json:""), GoTagMate will provide relevant suggestions for that specific tag. For example:- For
json:"", it suggestsomitempty,string, and-. - For
gorm:"", it suggestscolumn,type,index, and more. - For
validate:"", it suggestsrequired,email,rgb, and more.
- For
- After selecting a tag (e.g.,
-
Re-trigger Suggestions:
- If your cursor is inside double quotes (
"") and you type a space (), equal sign (=), semicolon (;), or comma (,), GoTagMate will re-trigger suggestions to help you complete the tag.
- If your cursor is inside double quotes (
-
Detailed Documentation:
- Hover over any suggested tag to see a detailed description of its purpose and usage examples.
-
User-Friendly:
- Designed to be intuitive and easy to use, even for beginners. No complex setup or configuration is required.
-
Extensible:
- GoTagMate is built to support additional libraries in the future. You can easily extend it to include custom tags or new libraries.
-
Backtick Trigger:
- The extension listens for the backtick character (`) in Go structs and automatically provides suggestions for
json:"",gorm:"", andvalidate:"".
- The extension listens for the backtick character (`) in Go structs and automatically provides suggestions for
-
Regex-Based Parsing:
- Uses regular expressions to detect the cursor's position and context (e.g., inside double quotes or after a specific tag type).
-
Dynamic Suggestions:
- Suggestions are dynamically generated based on the tag type (
json,gorm,validate) and the cursor's position.
- Suggestions are dynamically generated based on the tag type (
-
Library-Specific Tag Data:
- Tag data (e.g.,
gorm,validate) is stored in a modular and extensible format (tags.ts), making it easy to add support for new libraries.
- Tag data (e.g.,
-
Re-trigger on Specific Characters:
- The extension re-triggers suggestions when the cursor is inside double quotes and encounters specific characters (
,=,;,,).
- The extension re-triggers suggestions when the cursor is inside double quotes and encounters specific characters (
-
Markdown Documentation:
- Detailed documentation for each tag is displayed in a Markdown format when hovering over a suggestion.
-
Optimized Performance:
- The extension is designed to be lightweight and fast, ensuring minimal impact on VSCode's performance.
-
Modular Codebase:
- The code is organized into reusable modules (e.g.,
completionProvider.ts,tags.ts) for easy maintenance and future extensions.
- The code is organized into reusable modules (e.g.,
- Open a Go file in VSCode.
- Start typing a struct field and add a backtick (`).
- GoTagMate will suggest
json:"",gorm:"", andvalidate:"". - Select a tag (e.g.,
json:""), and it will provide relevant suggestions (e.g.,omitempty,string). - Hover over any suggestion to see detailed documentation.
- If you're inside double quotes and type a space, equal sign, semicolon, or comma, GoTagMate will re-trigger suggestions to help you complete the tag.
- The extension uses a Completion Provider to detect the cursor's position and context.
- When a backtick is typed, it triggers the
provideCompletionItemsmethod, which suggests initial tags (json,gorm,validate). - Once a tag is selected, the extension uses regex to detect the tag type and provides library-specific suggestions.
- The
getJsonPropertiesmethod extracts JSON properties from the document forjson:""suggestions. - The
createCompletionItemmethod generates completion items with detailed documentation. - The extension re-triggers suggestions when specific characters (
,=,;,,) are encountered inside double quotes.
- Open VSCode.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X. - Search for "GoTagMate".
- Click the Install button.
- Open a Go file in VSCode.
- Start typing a struct field and add a backtick (`).
- Select a tag from the suggestions (e.g.,
json:""). - Use the suggestions to complete the tag.
- Hover over any suggestion to see detailed documentation.
-
JSON:
- Tags:
omitempty,string,-. - Description: Simplifies JSON serialization and deserialization.
- Tags:
-
GORM:
- Tags:
column,type,index,unique,constraint. - Description: Helps define database schema and relationships.
- Tags:
-
Validate:
- Tags:
required,email,rgb,min,max. - Description: Provides field validation for structs.
- Tags:
-
Add Support for More Libraries:
- Extend GoTagMate to support additional libraries like
xml,yaml, andbson.
- Extend GoTagMate to support additional libraries like
-
Custom Tag Definitions:
- Allow users to define custom tags and suggestions.
-
Enhanced Documentation:
- Add more detailed usage examples and links to official documentation.
-
Configuration Options:
- Add settings to enable/disable specific libraries or customize trigger characters.
We welcome contributions! If you'd like to add support for a new library or improve the extension, follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
GoTagMate is licensed under the MIT License. See the LICENSE file for details.
If you have any questions, suggestions, or issues, please open an issue on the GitHub repository. We'd love to hear from you!
GoTagMate is your go-to VSCode extension for working with Go struct tags. It simplifies the process of writing and managing tags, saving you time and reducing errors. Try it out today and experience the difference!
