diff options
| author | Paul Buetow <paul@buetow.org> | 2026-01-29 21:39:06 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-01-29 21:39:06 +0200 |
| commit | 599bdb74efcc97e86ce6023c1ae8265b1c2ff33b (patch) | |
| tree | 6642a7401de622efc90947586f4db7a3e6ccd75d /internal/mapr/token.go | |
| parent | a32f028487c2e0b9e3144cf82d4153d1cd4a5243 (diff) | |
refactor: improve Go best practices compliance
- Add explicit interface satisfaction checks (var _ Interface = (*Type)(nil)) for compile-time verification:
- TurboWriter implementations (DirectTurboWriter, TurboChannelWriter)
- Processor implementations (GrepLineProcessor, ChannellessLineProcessor)
- Parser implementations (genericParser, csvParser, genericKVParser, custom parsers, mimecastParser)
- Logger implementations (file, stdout)
- Handler implementations (ServerHandler, ClientHandler)
- Connector implementations (Serverless, ServerConnection)
- SSH callback implementations (KnownHostsCallback)
- Improve error handling with context wrapping (%w):
- SSH operations: GeneratePrivateRSAKey, Agent
- Query parsing: Query.parse
- SSH client connections: dial, session, handle methods
- Fix receiver consistency:
- Convert Query.String() from value to pointer receiver
- Convert Outfile.String() from value to pointer receiver
- Convert all KnownHostsCallback methods to pointer receivers
- Convert mapCommand.Start() to pointer receiver
- Reorganize file structure for better clarity:
- internal/io/dlog/dlog.go: Move type definition before public functions
- internal/mapr/token.go: Reorganize helper functions after public ones
- Add documentation comments:
- Query.String() method
- Outfile.String() method
- Regex.String() method
- Improve config variable documentation
All unit tests and integration tests pass.
Amp-Thread-ID: https://ampcode.com/threads/T-019c0b08-0eeb-705d-a1f7-31bb764b659a
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/mapr/token.go')
| -rw-r--r-- | internal/mapr/token.go | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/internal/mapr/token.go b/internal/mapr/token.go index 77362f7..b9b02f8 100644 --- a/internal/mapr/token.go +++ b/internal/mapr/token.go @@ -14,22 +14,7 @@ type token struct { quotesStripped bool } -func (t token) isKeyword() bool { - if !t.isBareword { - return false - } - for _, keyword := range keywords { - if strings.ToLower(t.str) == keyword { - return true - } - } - return false -} - -func (t token) String() string { - return t.str -} - +// tokenize parses a query string into tokens. func tokenize(queryStr string) []token { var tokens []token for i, part := range strings.Split(queryStr, "\"") { @@ -105,3 +90,19 @@ func tokensConsumeOptional(tokens []token, optional string) []token { } return tokens } + +func (t token) isKeyword() bool { + if !t.isBareword { + return false + } + for _, keyword := range keywords { + if strings.ToLower(t.str) == keyword { + return true + } + } + return false +} + +func (t token) String() string { + return t.str +} |
